Metadata-Version: 2.4
Name: basedb
Version: 0.2.0
Summary: Low-level MariaDB/MySQL table abstraction layer
Author-email: Joseph Areeda <joseph.areeda@ligo.org>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://git.ligo.org/dqr-builder/dqr_basedb
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Natural Language :: English
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Astronomy
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: mysql-connector-python
Provides-Extra: test
Requires-Dist: pytest>=2.8.0; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Dynamic: license-file

# basedb

[![PyPI version](https://img.shields.io/pypi/v/basedb.svg)](https://pypi.org/project/basedb/)
[![License: GPL v3](https://img.shields.io/badge/License-GPL_v3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Docs](https://img.shields.io/badge/docs-dqr--builder.docs.ligo.org-blue.svg)](https://dqr-builder.docs.ligo.org/dqr_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

```bash
pip install basedb
```

## Quick Start

Subclass `Row` to define your schema, then subclass `Table` to wrap it:

```python
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](LICENSE.txt).
