Skip to main content

Firebirdsql wrapper inspired by subprocess.run

Project description

firebirdsql-run

Firebirdsql wrapper inspired by subprocess.run

PyPI: Version GitHub: Release Documentation CI: pre-commit CI: Main CI: Coverage

InstallationExamplesEnv Variables

Installation

pip install firebirdsql-run
# or
poetry add firebirdsql-run

Examples

Execute a query with read-only access:

from firebirdsql_run import DBAccess, execute

# Execute a query with read-only access.
result = execute(query="SELECT * FROM table", db="database", access=DBAccess.READ_ONLY)

# Output: List of dictionaries containing the query results.
print(result.data)

Execute a query with parameters and log the result:

# Execute a query with parameters.
result = execute(query="INSERT INTO customers (name, age) VALUES (?, ?)", params=("John", 25))

# Log the result.
if result.returncode != 0:
    logger.error(result)
else:
    logger.info(result)

Execute a query using the existing connection:

# Create a connection object.
conn = connection(db="database", access=DBAccess.READ_ONLY)
# Execute a query using the existing connection.
result = execute(query="SELECT * FROM table", use_conn=conn)
# Close the connection.
conn.close()

# Output: Named tuple representing the completed transaction.
print(result)

An example of a successful transaction:

>>> print(result)
CompletedTransaction(
    host="127.0.0.1",
    db="database",
    user="TWUSER",
    access="READ_ONLY",
    returncode=0,
    exception="",
    query="SELECT * FROM table",
    params=(),
    time=0.001,
    data=[
        {'id': 1, 'name': 'John Doe', 'department': 'Sales'},
        {'id': 2, 'name': 'Jane Smith', 'department': 'Sales'},
    ],
)

An example of a failed transaction:

>>> print(result)
CompletedTransaction(
    host="127.0.0.1",
    db="database",
    user="TWUSER",
    access="READ_ONLY",
    returncode=1,
    exception="Dynamic SQL Error\nSQL error code = -204\nTable unknown\ntable\nAt line 1, column 15\n",
    query="SELECT * FROM table",
    params=(),
    time=0.001,
    data=[],
)

Env Variables

FIREBIRD_KEY=

The FIREBIRD_KEY environment variable can be overridden with the functions argument passwd.

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

firebirdsql_run-1.1.4a0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

firebirdsql_run-1.1.4a0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file firebirdsql_run-1.1.4a0.tar.gz.

File metadata

  • Download URL: firebirdsql_run-1.1.4a0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for firebirdsql_run-1.1.4a0.tar.gz
Algorithm Hash digest
SHA256 ccf39ead7753325361caedfcd41b6a1d2a83dfa3a8b64dc389c61160f4634095
MD5 286a7b311f1d6e54a6a98646ef8e4bcf
BLAKE2b-256 e7179800188563b0470e30c4b320c65a379cf3aeaa9d7f584269c86a5c616c33

See more details on using hashes here.

File details

Details for the file firebirdsql_run-1.1.4a0-py3-none-any.whl.

File metadata

File hashes

Hashes for firebirdsql_run-1.1.4a0-py3-none-any.whl
Algorithm Hash digest
SHA256 b96aa4c299f53c7f7bee9a68fd8e4bd1b040caadf228b2f160868548860b576c
MD5 03384b6c160cb08fc58053b8ed8db2b6
BLAKE2b-256 cf8473c8aee983fd76fb2707f90f9c9c7db174f66aec2a1c28af270bc4d005d7

See more details on using hashes here.

Supported by

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