Skip to main content

sqlite3dict

Wrapper around sqlite3 which allows working simply with python dictionaries as well as combining it with sql syntax.

Installation

Use the package manager pip to install sqlite3dict.

pip install sqlite3dict

Usage

from sqlite3dict import Storage

from datetime import datetime

# ******************************************************************************
# * Test
# ******************************************************************************
with Storage("test.sqlite") as store:

    definitions = {
        "name": "TEXT", 
        "age": "INTEGER", 
        "amount": "DOUBLE", 
        "createdate": "DATETIME",
        "resident": "BOOLEAN"
    }

    # This creates the table (collection) only if it does not exist already
    collection = store.init_collection("test", definitions)

    # Insert data
    collection.insert({
        "name": "John Doe", 
        "age": 25, 
        "amount": 100.23, 
        "createdate": datetime.now(),
        "resident": True,
        "additional": {
            "prop1": 1,
            "prop2": 1,
            "other": ["A", "B"]
        }
    })

    collection.insert({
        "name": "John Doe", 
        "age": 10, 
        "amount": 100.00, 
        "createdate": datetime.now(),
        "resident": True
    })

    # Update inserted data by given criteria
    collection.update().data({
        "createdate": datetime.now(), 
        "age": 15, 
        "amount": 99.38, 
        "resident": False
    }).where("age = 25").execute()

    # Simple query for data
    list = collection.query().where("age = 15").limit(10).offset(0).order("createdate", "ASC").order("ID").execute()

    for item in list:
        print("item:", item)

    # Delete data by given criteria
    collection.delete().where("age = 15").execute()

    # Native SQL query in case you still need it
    items = store.query_native("select * from test")
    for item in items:
        print("native item:", item)

    # Drop table (collection)    
    store.delete_collection("test") 

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Release files for sqlite3dict 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlite3dict 1.0.1
File Size Uploaded
sqlite3dict-1.0.1.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlite3dict 1.0.1
File Interpreter ABI Platform
sqlite3dict-1.0.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 16.5 kB

Release files / sqlite3dict-1.0.1.tar.gz

Download URL sqlite3dict-1.0.1.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9cc282a9ff3edc9567ac62f53a4a9ad65e5a55161d4b3479de2452f9b0baa3f2
BLAKE2b-256 checksum
How to use checksums
115233f537996c3b55f4b8bd2d2990c49e13e66fcd29dbc5bdcd8aebebb0398a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release files / sqlite3dict-1.0.1-py2.py3-none-any.whl

Download URL sqlite3dict-1.0.1-py2.py3-none-any.whl
Size 9.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
27a3b1d54b162a256be421e864e9f010252ec5c119edae36e10464f4d6a18833
BLAKE2b-256 checksum
How to use checksums
c1b6b00c0da8870b815c71171baebe2354115d0d1877b26077003df01c05c307
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page