Skip to main content

This project is deprecated since the class Database exists in the library Shared



Litedao

Intuitive interaction with SQLite database

This project is part of the Pyrustic Ecosystem.

Installation | Reference | Shared

Overview

Here is an example of an interaction with an SQL database:

from litedao import Litedao


# Database path (if this file does not exist, it will be created)
DATABASE_PATH = "/home/alex/litedao_test.db"


# SQL code to initialize the database
INIT_SCRIPT = """\
CREATE TABLE friend (username TEXT PRIMARY KEY, email TEXT NOT NULL);
CREATE TABLE enemy (username TEXT PRIMARY KEY, email TEXT NOT NULL)"""


# Insertion SQL code
INSERTION_SQL = """\
INSERT INTO friend (username, email)
VALUES (?, ?), (?, ?)"""


# Selection SQL code
SELECTION_SQL = "SELECT * from friend"


def insert_data(litedao):
    # inserts data in the database then returns a boolean
    return litedao.edit(INSERTION_SQL, param=("alex", "alex@earth.invalid",
                                       "rustic", "rustic@earth.invalid"))


def select_data(litedao):
    # returns the selection
    return litedao.query(SELECTION_SQL)


# litedao instance
litedao = Litedao(DATABASE_PATH, init_script=INIT_SCRIPT)

# insert data if this database is newly created
if litedao.is_new:
    insert_data(litedao)


selection = select_data(litedao)
tables = litedao.tables()
columns = litedao.columns("friend")

litedao.close()  # if you forget to close Litedao, it will close itself at exit

print(selection)
# output: (['username', 'email'], [('alex', 'alex@earth.invalid'), ('rustic', 'rustic@earth.invalid')])

print(tables)
# output: ['friend', 'enemy']

print(columns)
# output: [(0, 'username', 'TEXT', 0, None, 1), (1, 'email', 'TEXT', 1, None, 0)]

Read the reference !

Do you need to store data collections with another simpler paradigm ? Check Shared !

Installation

pip install litedao

Metadata

Release files for litedao 0.0.7

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

Source distribution (sdist)

Source distribution for litedao 0.0.7
File Size Uploaded
litedao-0.0.7.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for litedao 0.0.7
File Interpreter ABI Platform
litedao-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 15.7 kB

Release files / litedao-0.0.7.tar.gz

Download URL litedao-0.0.7.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
74ea066877aff86a04d5c8e607b8bf5098cb45cc3d18711fcc151ce9bb62857c
BLAKE2b-256 checksum
How to use checksums
546f15be947d39898b253609d521ea57bcc0e6911c88653b4cb101e0cedb3252
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.6.1 requests/2.9.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.5.2

Release files / litedao-0.0.7-py3-none-any.whl

Download URL litedao-0.0.7-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
532ecde63ea5dc17783a35256a525042870d8dc5d63016e8bcb0ca6b57d2afea
BLAKE2b-256 checksum
How to use checksums
f430ff1440f73ec7b7648004c73af11f97425a388c374d12dbcb2e3b450776a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.6.1 requests/2.9.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.5.2

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

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