Firebirdsql wrapper inspired by subprocess.run
Project description
firebirdsql-run
Firebirdsql wrapper inspired by subprocess.run
Installation • Examples • Env 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
Release history Release notifications | RSS feed
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.3.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file firebirdsql_run-1.1.3.tar.gz
.
File metadata
- Download URL: firebirdsql_run-1.1.3.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31c07bff9b7063f11db5b868ec52ffc2cbbf6db02897a5aae7fce3c7e71b5866 |
|
MD5 | 766ea473d7cb62ec6e3ffb1bb59e0c57 |
|
BLAKE2b-256 | f6098a6d08ed3f25ebada4a5070f76aa86006a5f9ca0d8a0733783a218493a4d |
File details
Details for the file firebirdsql_run-1.1.3-py3-none-any.whl
.
File metadata
- Download URL: firebirdsql_run-1.1.3-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | adbcafdf4a1ec9b1d531097111b0c9aab2a61f3d22dd7f1fa7f72c121d23902c |
|
MD5 | 2eb49a5086c5aeee2a91b38fa68a3997 |
|
BLAKE2b-256 | f3e6fe548da8a885cc83cb4587a84e8fe914752c99c62659cdcdd0e14afc5d4e |