Skip to main content

Execute simple SQLite statements that are multithreaded/multiprocess safe

Project description

Tests Coverage

msqlite

Multi-threaded/multi-process support on top of SQLite. The intent is to ensure a SQL statement will get executed, even if other threads or processes are trying to access the DB. Avoids database is locked issues.

No additional package dependencies beyond regular Python.

Intended for relatively simple SQL statement execution. Locks the DB file on every access, with built-in retry mechanism.

Even though the DB is locked on every access, typically simple writes are much less than 1 second (more like 1 mS), so this latency is still usable for many use cases.

    table_name = "example"
    schema = {"id PRIMARY KEY": int, "name": str, "color": str, "year": int}
    db_path = Path("temp", "example.sqlite")
    db_path.parent.mkdir(exist_ok=True)

    # Write and read data.
    with MSQLite(db_path, table_name, schema) as db:
        now = time.monotonic_ns()  # some index value
        # insert some data
        db.execute(f"INSERT INTO {table_name} VALUES ({now}, 'plate', 'red', 2020), ({now + 1}, 'chair', 'green', 2019)")
        # read the data back out
        response = db.execute(f"SELECT * FROM {table_name}")
        for row in response:
            print(row)

    # Read data out. No longer needs the schema.
    with MSQLite(db_path, table_name) as db:
        response = db.execute(f"SELECT * FROM {table_name}")
        for row in response:
            print(row)

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

msqlite-0.7.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

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

msqlite-0.7.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file msqlite-0.7.2.tar.gz.

File metadata

  • Download URL: msqlite-0.7.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for msqlite-0.7.2.tar.gz
Algorithm Hash digest
SHA256 680607f127be3315b7c1f6c1b3ded83b738a0666508a4d4cc6715aa5f9b3bc75
MD5 a41d0f25154b3b3c3c722c08566f2f3e
BLAKE2b-256 5b9a83977e431c63fe3c24516e14ff149409a6c3b6b6dbb7d6633029922c6bf4

See more details on using hashes here.

Provenance

The following attestation bundles were made for msqlite-0.7.2.tar.gz:

Publisher: publish.yml on jamesabel/msqlite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file msqlite-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: msqlite-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for msqlite-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3561537caad5b2a6d67e7dd8d04c12571a143c9ee2419acf1a7d9a59d38401ff
MD5 4cea49aaddca1a736c73676ffa9adb25
BLAKE2b-256 80cc82f80c07568cbddbd836ef75dbe5ba04fbca33f0674dbe87da49b9bb335a

See more details on using hashes here.

Provenance

The following attestation bundles were made for msqlite-0.7.2-py3-none-any.whl:

Publisher: publish.yml on jamesabel/msqlite

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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