sql-adapters
A Python library that wraps SQLAlchemy core to deliver an opinionated style of development wherein databases are implemented as adapters which are interfaces to the data source.
import sql_adapters.sqlite as sql
from sql_adapters import (
Column,
declarative_base,
delete,
insert,
select,
text,
update,
)
base = declarative_base()
class _TestTable(base):
__tablename__ = "test_table"
id = Column(sql.INTEGER, primary_key=True, autoincrement=True)
name = Column(sql.TEXT, nullable=False)
date_created = Column(
sql.TZDateTime,
nullable=False,
default=lambda: datetime.now().astimezone(),
)
class returns:
class select_result(NamedTuple):
id: int
name: str
date_created: datetime
class DemoAdapter(sql.SqliteAdapter):
def __init__(
self,
read_only: bool = False,
):
super().__init__("test", mode="ro" if read_only else "rw")
@staticmethod
def init():
adapter = DemoAdapter(read_only=False)
with adapter:
base.metadata.create_all(adapter.connection)
def add_item(self, name: str):
self.execute(insert(_TestTable).values(name=name))
def get_item(self, item_id: int) -> returns.select_result:
stmt = select(_TestTable).where(_TestTable.id == item_id)
result = self.execute(stmt)
data = self.read_values(result, returns.select_result)
return next(data)
Metadata
Release files for sql-adapters 0.3.0
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 | Actions |
|---|---|---|---|---|
| sql_adapters-0.3.0.tar.gz | 4.5 kB | Without provenance | Details for sql_adapters-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sql_adapters-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for sql_adapters-0.3.0-py3-none-any.whl |
Total release size: 10.8 kB
Release files / sql_adapters-0.3.0.tar.gz
| Download URL | sql_adapters-0.3.0.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1aaf25e43cfc6abb673570b41e9007e5432c9f92bc64f46a36a0dcdb9edec595
|
|
BLAKE2b-256 checksum How to use checksums |
46e710a0f7528bf4c66780f9611eab5f8202b9a468593a55540cb94f5cddd1f8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.22
|
Release files / sql_adapters-0.3.0-py3-none-any.whl
| Download URL | sql_adapters-0.3.0-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2bc8596a10119c90c1ebf189b0bb3c8ace416c69b23bb7795fbe73690b8ef129
|
|
BLAKE2b-256 checksum How to use checksums |
db00f874d687aa19857fde32db7f49f5c09f41b8378378f2cefb5a31323e2836
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.22
|
Security for sql-adapters 0.3.0
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.