Skip to main content

A Rust-powered Python library for scheduled SQLite operations.

Project description

sqlite-scheduler

A Rust-powered Python library for scheduled SQLite operations.

  • Python 3.9+
  • Rust-backed SQLite I/O via rusqlite
  • Built-in interval scheduler running in a native thread
  • Optional integration with the popular Python schedule package

Build

maturin develop

Usage

With the Python schedule package

import sqlite_scheduler
import schedule
import time

def job():
    sqlite_scheduler.execute_sql(
        "app.db",
        "INSERT INTO logs(msg) VALUES (?)",
        parameters=["heartbeat"],
    )

schedule.every(10).seconds.do(job)
while True:
    schedule.run_pending()
    time.sleep(1)

With the built-in scheduler

from sqlite_scheduler import SqliteScheduler

scheduler = SqliteScheduler("app.db")
scheduler.add_interval_job(10, "INSERT INTO logs(msg) VALUES ('tick')")
scheduler.start(blocking=False)
# ...
scheduler.stop()

Basic CRUD

import sqlite_scheduler

sqlite_scheduler.execute_sql(
    "app.db",
    "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)",
)

rows = sqlite_scheduler.execute_sql(
    "app.db", "SELECT * FROM users", fetch=True
)
print(rows)  # [{'id': 1, 'name': 'Alice'}, ...]

Run tests

pytest

Examples

See the examples/ directory.

python examples/basic_crud.py
python examples/builtin_scheduler.py
python examples/with_schedule_package.py

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

sqlite_scheduler-0.1.0-cp39-abi3-win_amd64.whl (958.0 kB view details)

Uploaded CPython 3.9+Windows x86-64

File details

Details for the file sqlite_scheduler-0.1.0-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for sqlite_scheduler-0.1.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 c2d0ce296299fce2469253a7a1d8387c3b0c807a079d95c7e0489b4f2cadf226
MD5 39cf05e23fa0b346c4e881a7d8f7e634
BLAKE2b-256 7a70a2577a19c5445d96b8c12bde6dfef85b469d22add0f3771104b11233de45

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