Python Connector for SQLite

Connection parameters - Python Connector for SQLite

Connection parameters

The following table describes SQLite connection parameters you can use in the connect() module method.

Parameter Description

Database

The path to the SQLite database file

Direct

Enables a direct connection to the database, which doesn't require the SQLite client library. The default value is True.

EncryptionAlgorithm

The encryption algorithm for accessing an encrypted database. The possible values are:

  • TripleDES
  • Blowfish
  • AES128
  • AES192
  • AES256
  • Cast128
  • RC4

EncryptionKey

The encryption key for accessing an encrypted database

ClientLibrary

The path to the SQLite library.

This parameter is available when Direct is set to False.

ForceCreateDatabase

Specifies whether to create a database when opening a connection if the database specified in the Database parameter doesn't exist. The default value is False.

ConnectMode

The connection mode. The possible values are:
  • Default – (Default) Open a database in the default mode.
  • ReadWrite – Open a database for reading and writing.
  • ReadOnly – Open the database in read-only mode.

LockingMode

The database locking mode. The possible values are:
  • Normal – (Default) The database connection unlocks the database file after each read or write transaction.
  • Exclusive – The database connection never releases file locks. The first time the database is read or written in this mode, a shared lock is obtained and held. Use this mode to prevent other processes from accessing the database file, reduce the number of filesystem operations, or access WAL databases without using the shared memory.

JournalMode

The journal mode. The possible values are:
  • Default – If the database was previously opened in the WAL mode, then Default will open the database in the WAL mode. Otherwise, the database will be opened in the Delete mode.
  • Delete – The rollback journal is deleted after each transaction.
  • Truncate – Commit transactions by truncating the rollback journal to zero-length instead of deleting it. On many systems, truncating a file is much faster than deleting the file since the containing directory doesn't need to be changed.
  • Persist – The rollback journal file isn't deleted when the transaction is committed. The journal header is filled with zeroes to prevent other connections from rolling back from the journal. This mode optimizes performance on platforms where deleting or truncating a file is much more expensive than overwriting the first block of a file with zeros.
  • Memory – The rollback journal is stored in volatile RAM. This reduces the disk I/O but decreases database safety and integrity. If the application using SQLite crashes in the middle of a transaction in this mode, the database file is likely to become corrupt.
  • WAL – A write-ahead log is used instead of a rollback journal to implement transactions. When a database is updated, the original content is preserved in the database file, and the changes are appended in a separate WAL file. All the transactions that are appended in the WAL file are eventually transferred back into the original database.
  • Off – The rollback journal is completely disabled. No rollback journal is created, and there's no rollback journal to delete. The ROLLBACK command doesn't work — it behaves in an undefined way. Avoid using the ROLLBACK command when the journal mode is disabled.

Synchronous

The database synchronization mode. The possible values are:
  • Normal – (Default) The database engine still syncs at the most critical moments but less often than in the FULL mode. The Normal mode is faster than the Full mode. When using the WAL mode (and probably the DELETE mode) with synchronous=NORMAL, data is safe from corruption. The synchronous=NORMAL setting is a reasonable choice for most applications running in the WAL mode.
  • Full – The database engine ensures that all content is safely written to disk before continuing. This preserves database integrity even in case of an operating system failure or power outage. It is a safe but slower mode, and is most commonly used when not in the WAL mode.
  • Extra – This mode is similar to the FULL mode, but in the DELETE mode, the directory containing the rollback journal is synced after that journal is unlinked to commit a transaction. This provides additional durability if a power outage occurs right after the commit.
  • Off – The database engine continues without syncing after handing data off to the operating system. If the application running SQLite crashes, the data will save unless the operating system crashes or the computer loses power before data has been written to disk, in which case the database might become corrupted. This is the fastest mode.

PoolId

The ID of a connection pool that will be used for a particular connection

DisablePooling

Disables connection pooling for a particular connection.

The possible values are True and False. The default value is False.

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