Skip to main content

Firebirdsql wrapper inspired by subprocess.run

Project description

firebirdsql-run

Firebirdsql wrapper inspired by subprocess.run

PyPI version Documentation Main pre-commit.ci codecov

Installation

pip install 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:

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

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

Execute a query using the existing connection:

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

# Output: 0 (success) or 1 (error).
print(result.returncode)

Completed transaction

When you execute a query, firebirdsql-run returns a CompletedTransaction object.

Queried table:

maker model type
B 1121 PC
A 1232 PC

An example of a successful transaction:

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=[
        {"maker": "B", "model": 1121, "type": "PC"},
        {"maker": "A", "model": 1232, "type": "PC"},
    ],
)

An example of a failed transaction:

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.1a2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

firebirdsql_run-1.1.1a2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file firebirdsql_run-1.1.1a2.tar.gz.

File metadata

  • Download URL: firebirdsql_run-1.1.1a2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for firebirdsql_run-1.1.1a2.tar.gz
Algorithm Hash digest
SHA256 5e42d01f1a8840a4cdfd240f5b97faa401a246f960952bb0922d6cda089d24c1
MD5 42179d6664a184e3a19aadbae7a1c0e5
BLAKE2b-256 afd1a2cc6a2277125765d1de92e680d085b9f5cba7a781772e2877151c5a2af3

See more details on using hashes here.

File details

Details for the file firebirdsql_run-1.1.1a2-py3-none-any.whl.

File metadata

File hashes

Hashes for firebirdsql_run-1.1.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 9147eceb76eaff2dcfb44e21097b8b3c7c7d588d95f8b6242fbdca4367e06c22
MD5 2c537ae5829719511bd9e0be09af5b02
BLAKE2b-256 f4a4677d30b7350fe7048477eb3d3994730d4661e22e69b8c6d75c0781695b36

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