Skip to main content

No project description provided

Project description

SQLite Class wrapper with auto-initialisation of empty DB

SQLiteDb class wrapping the operations from the sqlite3 module, providing better support for the with operator and automatic initialisation of an empty DB upon first creation of the DB.

Additional wrappers are available as a utility, including extraction of a list of tables, extraction of the list of columns of a SELECT query, commit, rollback, start of a transaction, check if the DB is in memory and if it's empty. Executions of SQL script files is also made easy.

Example usage

import sqlitecls

with sqlitecls.SqliteDb('mydata.db', 'myinitscript.sql') as db:
    # Now the DB connection is established and the DB is guaranteed
    # to be initialised, as if it the DB file was not existing before,
    # the init script is run, preparing it for whatever your
    # application has to do.
    #
    # You can easily check which tables are available
    tables = db.tables_names()
    # and what columns they have
    columns = db.columns_names('some_table')
    # Otherwise use as any other DB API from now on
    cursor = db.execute('SELECT * FROM mytable')
    # Simplified extraction of the column names from the SELECT query
    columns = sqlitecls.cursor_column_names(cursor)
    # Use as any other DB API from now on
    for row in cursor:
        pass  # Do something with each row
    db.connection, db.cursor  # Available for custom operations
    # More wrappers!
    db.start_transaction()
    db.commit()
    db.rollback()
    db.vacuum()
    # Have existing SQL script files? Just run them as they are!
    db.execute_sql_file('myotherfile.sql')  # Load WHOLE file in memory
# Connection automatically closed now

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SQLiteCls-0.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SQLiteCls-0.1.0-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file SQLiteCls-0.1.0.tar.gz.

File metadata

  • Download URL: SQLiteCls-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for SQLiteCls-0.1.0.tar.gz
Algorithm Hash digest
SHA256 15a394247f100a8af03e370fb96dc4abd101ef714ed14e52095984c5c1a30781
MD5 769d69a8b1f8bc01fe6c2e100f188ae3
BLAKE2b-256 a783382485731e102bce9a030118b2718b7ea9c32c8f365f3d7803eb4fad52d1

See more details on using hashes here.

File details

Details for the file SQLiteCls-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: SQLiteCls-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for SQLiteCls-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a82791a6415e6b896468104ae181cb4288c618b8c370cc693afb568dde42e51f
MD5 8fc0741953d22514f5e5c0aa568b02cb
BLAKE2b-256 0bc877805bad2fe35855f8aad434ed84d2f15739f58de537427b27d65b948b7f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page