To establish a connection to an SQLite database, import the connector and use the connect() method with your connection parameters.
First, import the SQLite connector module:
import devart.sqlite
Connect to a database using the connect() module method and obtain a connection object.
You can connect in Direct mode or by using a dynamically linked SQLite client library.
Direct mode
In Direct mode, the connector works without requiring an external SQLite client library. Provide the path to your database file:
my_connection = sqlite.connect(
Direct=True,
Database="your_database"
)
Replace the example value with the path to your actual database file.
For more information, see Connection parameters.
Dynamically linked SQLite client library
You can also connect using a dynamically linked SQLite client library. Provide the path to the client library file along with the database file:
my_connection = devart.sqlite.connect(
Direct=False,
Database="your_database",
ClientLibrary="your_sqlite_lib"
)
Replace the example values with your actual database and client library paths.
For more information, see Connection parameters.