English 中文(简体)
Python SQLite - Establishing Connection
  • 时间:2024-12-22

Python SQLite - Estabpshing Connection


Previous Page Next Page  

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

Command Prompt SQLite

Estabpshing Connection Using Python

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

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

    Import the sqpte3 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 sqpte3
conn = sqpte3.connect( example.db )

Output


print("Connection estabpshed ..........")
Advertisements