Python SQLite – Establishing Connection


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

”;

Leave a Reply

Your email address will not be published. Required fields are marked *