SQLAlchemy provider for init-provider
Project description
init-provider-sqlalchemy
Database provider implemented using init-provider.
Table of Contents
Quick start
Below is a full runnable example that uses everything in this library.
import asyncio
import os
from init_provider import setup, dispose
from init_provider_sqlalchemy import Database
from sqlalchemy import text
@setup
def configure() -> None:
os.environ["DATABASE_ENGINE_URL"] = "sqlite:///example.db"
os.environ["DATABASE_ENGINE_ASYNC_URL"] = "sqlite+aiosqlite:///example.db"
os.environ["DATABASE_ENGINE_ECHO"] = "False"
os.environ["DATABASE_SESSION_EXPIRE_ON_COMMIT"] = "False"
@dispose
def cleanup() -> None:
os.unlink("example.db")
def sync_test() -> None:
with Database.session() as session:
result = session.execute(text("SELECT 1"))
print(result.scalar())
async def async_test() -> None:
async with Database.async_session() as session:
result = await session.execute(text("SELECT 1"))
print(result.scalar())
async def main() -> None:
sync_test()
await async_test()
if __name__ == "__main__":
asyncio.run(main())
Installation
Using pip:
pip install init-provider-sqlalchemy
Using uv:
uv add init-provider-sqlalchemy
License
Licensed under the Apache-2.0 License.
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 init_provider_sqlalchemy-0.1.1.tar.gz.
File metadata
- Download URL: init_provider_sqlalchemy-0.1.1.tar.gz
- Upload date:
- Size: 62.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
039224fd7aa3cedb3ae6476ee56358538e7609e581757c1acd27e81bf384e0e5
|
|
| MD5 |
5c7c2692cc8336ca37623295fdecb59c
|
|
| BLAKE2b-256 |
decf372585c9c0609a2d73232bd5b759d22c3ade816a7fe170e29791b20c0632
|
File details
Details for the file init_provider_sqlalchemy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: init_provider_sqlalchemy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7d653125942b65b3ff8d628b9d6d8227e3858191126da16a02581ebfd410434
|
|
| MD5 |
8ca9e5b858e189aeb5e6d0a8e8dd3f46
|
|
| BLAKE2b-256 |
e3860b40077a82d1af15d1b0f5b69ec92e3bc040d1befbdd45fbe0efec2a691f
|