Python SQLite - Establishing Connection



To establish connection with SQLite Open command prompt, browse through the location of where you have installed SQLite and just execute the command sqlite3 as shown below −

Establish Connection

Establishing connection using python

You can communicate with SQLite2 database using the SQLite3 python module. To do so, first of all you need to establish a connection (create a connection object).

To establish a connection with SQLite3 database using python you need to −

  • Import the sqlite3 module using the import statement.

  • The connect() method accepts the name of the database you need to connect with as a parameter and, returns a Connection object.

Example

import sqlite3
conn = sqlite3.connect('example.db')

Output

print("Connection established ..........")
Advertisements
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy