PyDocs

Nav

Data Persistence

connect

sqlite3

function
  • connect(database, *, timeout=5.0, detect_types=0, isolation_level='DEFERRED', check_same_thread=True, factory=sqlite3.Connection, cached_statements=128, uri=False, autocommit=sqlite3.LEGACY_TRANSACTION_CONTROL)
Open a connection to the SQLite database file 'database'.

You can use ":memory:" to open a database connection to a database that
resides in RAM instead of on disk.
Changed in 3.4, 3.7, 3.10, 3.12, 3.15
  • 3.4: Added the uri parameter.
  • 3.7: database can now also be a path-like object, not only a string.
  • 3.10: Added the sqlite3.connect/handle auditing event.
  • 3.12: Added the autocommit parameter.
  • 3.15: All parameters except database are now keyword-only.
1 Example
>>> con = sqlite3.connect("file:tutorial.db?mode=ro", uri=True)
>>> con.execute("CREATE TABLE readonly(data)")
Traceback (most recent call last):
OperationalError: attempt to write a readonly database
>>> con.close()
from the Python docs
See Also
No see-alsos for sqlite3/connect
0 Notes
No notes for connect