Skip to main content

Firebird for SQLAlchemy

Project description

SQLAlchemy dialect for Firebird using pyfirebirdsql .

It based on sqlalchemy-firebird , thanks.

Requirements

It is difficult to support many versions, so I target newer versions.

  • Firebird 4.0+

  • SQLAlchemy 2.0+

  • Python 3.10+

Installation

pip install sqlalchemy_firebirdsql

Connection strings

A SQLAlchemy URL has the shape dialect+driver://username:password@host:port/database. For this dialect:

firebirdsql+syn://user:password@host:port/path/to/db[?key=value&key=value...]

For async:

firebirdsql+asyn://user:password@host:port/path/to/db[?key=value&key=value...]

The bare firebirdsql:// scheme defaults to the synchronous (syn) driver.

Examples

Local server, default port:

firebirdsql+syn://sysdba:masterkey@localhost//home/me/databases/my_project.fdb

Remote server on port 3050:

firebirdsql+syn://sysdba:masterkey@example.com:3050//srv/databases/my_project.fdb

Usage

Synchronous

from sqlalchemy import create_engine, text

engine = create_engine(
    "firebirdsql+syn://sysdba:masterkey@localhost//home/me/databases/my_project.fdb",
    echo=True,
)

with engine.connect() as conn:
    result = conn.execute(text("select 1 from rdb$database"))
    print(result.scalar())

Asynchronous

import asyncio
from sqlalchemy import text
from sqlalchemy.ext.asyncio import create_async_engine

engine = create_async_engine(
    "firebirdsql+asyn://sysdba:masterkey@localhost//home/me/databases/my_project.fdb",
    echo=True,
)

async def main():
    async with engine.connect() as conn:
        result = await conn.execute(text("select 1 from rdb$database"))
        print(result.scalar())

asyncio.run(main())

How to test

Clone and install

git clone git@github.com:nakagami/sqlalchemy_firebirdsql.git
cd sqlalchemy_firebirdsql
python3 -m venv .venv
. .venv/bin/activate
pip install -e .
pip install pytest

Create test database and execute pytest

prepare-test-environment
pytest --db syn
pytest --db asyn

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlalchemy_firebirdsql-0.1.0.tar.gz (53.9 kB view details)

Uploaded Source

File details

Details for the file sqlalchemy_firebirdsql-0.1.0.tar.gz.

File metadata

  • Download URL: sqlalchemy_firebirdsql-0.1.0.tar.gz
  • Upload date:
  • Size: 53.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for sqlalchemy_firebirdsql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f111817b080037b1f902b89c1b06a9e9cc0e84443869bacd8aa7ada58df07d1c
MD5 37b9f8f0b359885a5198bafc05d13b23
BLAKE2b-256 fa1b8bdd43a0dd8473501951f4e2be2286ff19f3f5329c47d348f81468a2c3ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page