HissDB is a SQLite3 frontend with a focus on ease-of-use and tight integration with Python syntax.
Installation
python3 -m pip install hissdb
Usage
Database Setup
from hissdb import Database
# make a new db or load one from an existing path
db = Database('test_location.db')
# add some tables to the database
users = db.create_table(
id = 'INTEGER PRIMARY KEY',
first_name = 'TEXT',
last_name = 'TEXT',
age = 'INTEGER',
)
posts = db.create_table(
user_id = 'INTEGER NOT NULL',
text = 'TEXT',
date = 'INTEGER',
foreign_keys = {'user_id': users.id},
)
Writing Data
# inserting a row returns the new rowid
jane_id = users.insert(first_name = 'Jane', last_name = 'Doe')
john_id = users.insert(first_name = 'John', last_name = 'Doe')
posts.insert(
user_id = john_id,
date = 20210817,
text = "I'm John Doe and this is my first post!"
)
# you can also insert many rows at once using a list or generator
posts.insertmany(
cols = ['user_id', 'date', 'text'],
rows = [
(jane_id, 20210814, "First!"),
(jane_id, 20210816, "The weather is nice today."),
(jane_id, 20210817, "Do you ever post on the internet just so there's content?"),
],
)
# you can update data based on matching criteria.
# for instance, let's add a signature to each of Jane's posts
posts.update(
text = posts.text + ' - ' + users.first_name,
where = users.id == jane_id,
)
# finally, we must write the changes to the file
db.commit()
Reading Data
# get all users
names = users.fetchall(cols=['first_name', 'last_name'])
assert names == [('Jane', 'Doe'), ('John', 'Doe')]
# get a single column
first_names = users.first_name.fetchall()
assert first_names == ['Jane', 'John']
# easily write WHERE queries
does = users.id.fetchall(where=users.last_name == 'Doe')
# an even simpler equivalent:
does = users.id.fetchall(last_name='Doe')
assert does = [1, 2]
# a few methods like startswith() have been translated to SQL expressions
users.insert(first_name='Dave', last_name='Guy')
non_j_name = users.first_name.fetchone(~users.first_name.startswith('J'))
assert non_j_name == 'Dave'
# you can construct all kinds of queries
full_names = users.fetchall(cols=(users.first_name + ' ' + users.last_name))
assert full_names == [('Jane Doe',), ('John Doe',), ('Dave Guy',)]
For more sample code using HissDB, see the tests.
If you're looking for more detailed documentation, check out the library reference.
Metadata
Release files for hissdb 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| hissdb-0.0.5.tar.gz | 30.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hissdb-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 63.1 kB
Release files / hissdb-0.0.5.tar.gz
| Download URL | hissdb-0.0.5.tar.gz |
|---|---|
| Size | 30.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c4e9f606207cee8838fbf26092760cc8018ec079d822dcb72b9b2a142fc0775
|
|
BLAKE2b-256 checksum How to use checksums |
a29c6bc8ed1ff2e561966202d991c2a1a7a533c3a9255cbdc25bbbb512cc45f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.13
|
Release files / hissdb-0.0.5-py3-none-any.whl
| Download URL | hissdb-0.0.5-py3-none-any.whl |
|---|---|
| Size | 32.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
010982a78838b1c77c7dd59384b0dc384de694588d3a5f9fef215d93a8227346
|
|
BLAKE2b-256 checksum How to use checksums |
c83b2f8800e863ced3ddb5ad2a66fa6883f5994444aac18658dbee83a94c3fb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.13
|
Security for hissdb 0.0.5
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.