Skip to main content

init-provider-sqlalchemy

Database provider implemented using init-provider.

PyPI - Version PyPI - Python Version PyPI - Status PyPI - License

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.

Metadata

Release files for init-provider-sqlalchemy 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for init-provider-sqlalchemy 0.1.1
File Size Uploaded
init_provider_sqlalchemy-0.1.1.tar.gz 62.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for init-provider-sqlalchemy 0.1.1
File Interpreter ABI Platform
init_provider_sqlalchemy-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 69.8 kB

Release files / init_provider_sqlalchemy-0.1.1.tar.gz

Download URL init_provider_sqlalchemy-0.1.1.tar.gz
Size 62.2 kB
Tags Source
SHA-256 checksum
How to use checksums
039224fd7aa3cedb3ae6476ee56358538e7609e581757c1acd27e81bf384e0e5
BLAKE2b-256 checksum
How to use checksums
decf372585c9c0609a2d73232bd5b759d22c3ade816a7fe170e29791b20c0632
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.0

Release files / init_provider_sqlalchemy-0.1.1-py3-none-any.whl

Download URL init_provider_sqlalchemy-0.1.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7d653125942b65b3ff8d628b9d6d8227e3858191126da16a02581ebfd410434
BLAKE2b-256 checksum
How to use checksums
e3860b40077a82d1af15d1b0f5b69ec92e3bc040d1befbdd45fbe0efec2a691f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.0

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page