Python Connector for SQLite

Connecting to SQLite - Python Connector for SQLite

Connecting to SQLite

To establish a connection to an SQLite database, import the connector and use the connect() method with your connection parameters.

Step 1. Import the connector

First, import the SQLite connector module:

import devart.sqlite

Step 2. Establish a connection

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.

© 2022-2025 Devart. All Rights Reserved. Request Support Python Connectors Forum Provide Feedback