Skip to main content

Library for interacting with the SQLite database.

Installation:

pip install mwsqlite

Example:

from mwsqlite import MWBase, Where, Order, DESC, ASC

# create database object (1)
base = MWBase(
    filename="file.db",
    tables={
        "users": {
            "first_name": str,
            "last_name": str,
            "middle_name": str,
            "age": int,
            "info": dict,
            "is_admin": bool,
            "list_rewards": list,
        }
    }
)

# add user to database
base.users.add(
    first_name="John",
    last_name="Doe",
    middle_name="Smith",
    age=18,
    info={"description": "some info"},
    is_admin=False,
    list_rewards=[{"id": 1, "name": "reward1"}, {"id": 2, "name": "reward2"}],
)

# get one user from database
user = base.users.get_one(name="John", age=18)
print(user)
# MWBase.users.Row({'first_name': 'John', 'last_name': 'Doe', 'middle_name': 'Smith', 'age': 18, 'info': {'description': 'some info'}, 'is_admin': False, 'list_rewards': [{'id': 1, 'name': 'reward1'}, {'id': 2, 'name': 'reward2'}]})

base.users.update(
    Where(first_name="John"),
    first_name="Jane",
)

user = base.users.get_one(name="Jane", age=18)
print(user)
#  MWBase.users.Row({'first_name': 'Jane', 'last_name': 'Doe', 'middle_name': 'Smith', 'age': 18, 'info': {'description': 'some info'}, 'is_admin': False, 'list_rewards': [{'id': 1, 'name': 'reward1'}, {'id': 2, 'name': 'reward2'}]})

print(user.age)
# 18
user.update(age=19)
print(user.age)
# 19

user.delete()

user = base.users.get_one(name="Jane", age=18)
print(user)
# None

# get many users from database

for i in range(3):
    base.users.add(first_name="John", age=18 + i)

users = base.users.get(
    Order(age=DESC), 
    name="John"
)
print(len(users))
# 3

print(users)
# [{'first_name': 'Jane', 'last_name': '', 'age': 0, 'info': {}, 'is_admin': False, 'list_rewards': []}, ...]

for user in users:
    print(user.age)
    # 20
    # 19
    # 18

Metadata

Release files for mwsqlite 1.3.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 mwsqlite 1.3.1
File Size Uploaded Provenance Actions
mwsqlite-1.3.1.tar.gz 8.2 kB Without provenance Details for mwsqlite-1.3.1.tar.gz

Release files / mwsqlite-1.3.1.tar.gz

Download URL mwsqlite-1.3.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6c82a06f57a2ff0428cab0f2e46a36fa865494d2a96217356ca06ddabb413525
BLAKE2b-256 checksum
How to use checksums
794aece7df9cda0bf017d02e7bec28c783d51be2562a120cee3305f54f41063c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.2

Security for mwsqlite 1.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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