How to create a Database instance

This commit is contained in:
Simon Willison 2021-08-11 04:56:54 -07:00 committed by GitHub
commit af89c5f851
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -251,6 +251,13 @@ class Database:
"""
Wrapper for a SQLite database connection that adds a variety of useful utility methods.
To create an instance::
# create data.db file, or open existing:
db = Database("data.db")
# Create an in-memory database:
dB = Database(memory=True)
- ``filename_or_conn`` - String path to a file, or a ``pathlib.Path`` object, or a
``sqlite3`` connection
- ``memory`` - set to ``True`` to create an in-memory database