Metadata-Version: 2.4
Name: sqlalchemy_firebirdsql
Version: 0.1.0
Summary: Firebird for SQLAlchemy
Author: F.D.Castel
Author-email: Paul Graves-DesLauriers <paul@dexmicro.com>, Hajime Nakagami <nakagami@gmail.com>
Maintainer-email: Hajime Nakagami <nakagami@gmail.com>
License: Copyright 2005-2026 SQLAlchemy authors and contributors <see AUTHORS file>.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of
        this software and associated documentation files (the "Software"), to deal in
        the Software without restriction, including without limitation the rights to
        use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
        of the Software, and to permit persons to whom the Software is furnished to do
        so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Keywords: SQLAlchemy,Firebird,firebirdsql
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Database :: Front-Ends
Classifier: Operating System :: OS Independent
Description-Content-Type: text/x-rst
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: sqlalchemy>=2.0
Requires-Dist: firebirdsql
Dynamic: license-file

============================
sqlalchemy-firebirdsql
============================

`SQLAlchemy <https://www.sqlalchemy.org/>`_ dialect
for `Firebird <https://firebirdsql.org/en/start/>`_
using `pyfirebirdsql <https://github.com/nakagami/pyfirebirdsql>`_ .

It based on `sqlalchemy-firebird <https://github.com/pauldex/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
-----------

.. code-block:: python

   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
------------

.. code-block:: python

   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

