Low-level MariaDB/MySQL table abstraction layer
Project description
basedb
basedb is a thin, pure-Python abstraction layer over MariaDB/MySQL.
It provides Column, Row, Table, and Database base classes that
handle DDL generation, value marshalling, and connection management —
without hiding the SQL.
Installation
pip install basedb
Quick Start
Subclass Row to define your schema, then subclass Table to wrap it:
from basedb.database import Database
from basedb.row import Row
from basedb.table import Table
class MyRow(Row):
def get_col_def(self):
defs = [
{'name': 'id', 'type': int, 'length': 4, 'primary': True,
'autoincrement': True},
{'name': 'label', 'type': str, 'length': 64, 'notNull': True},
{'name': 'value', 'type': float},
]
cols, _ = self.define_cols(defs)
return cols
class MyTable(Table):
def __init__(self, db):
self.row = MyRow()
super().__init__(db, 'my_table', columns=self.row.get_col_def())
self.row = MyRow()
db = Database(host='localhost', user='dqr', password='s3cr3t', database='mydb')
t = MyTable(db)
t.create(ifnotexists=True)
row = MyRow()
row.set({'label': 'alpha', 'value': 3.14})
t.insert(row)
db.commit()
results = t.select(where='label = "alpha"')
print(results[0]['value']) # → 3.14
db.close()
Documentation
Full documentation — including a column type reference and a detailed subclassing guide — is available at:
https://dqr-builder.docs.ligo.org/dqr_basedb/
License
basedb is distributed under the GNU General Public License v3 or later.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file basedb-0.2.0.tar.gz.
File metadata
- Download URL: basedb-0.2.0.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b30fe1a3517d3175443b6f30cdfe9f8cba700c0e1b1e2885a13761b4c4b50f3f
|
|
| MD5 |
9339230a656d425b7c641b3565df06f3
|
|
| BLAKE2b-256 |
4b68079a3805f02bdcfaac6a7e6eeac99d88bc72f1de856ec7085a34545acb0a
|
File details
Details for the file basedb-0.2.0-py3-none-any.whl.
File metadata
- Download URL: basedb-0.2.0-py3-none-any.whl
- Upload date:
- Size: 35.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81bf379313c626f3ff405612f7fa94922a5de7d396d602878944b8144c391d99
|
|
| MD5 |
f504fb5be9d588e2398234466c7e93b8
|
|
| BLAKE2b-256 |
ec74f4b202df5da9c4c04a04d00a636e11ae44df6a5c63707ff9877e76faa992
|