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
Built Distribution
Close
Hashes for firebirdsql_run-1.1.2b1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3117b0a53c9877acf06eeea9d0b15e3f19add9f4cfc05b1c1641ed9d4bce97c |
|
MD5 | 53cf7db883c67594d955c7653845539b |
|
BLAKE2b-256 | 0d29b3287b744e0ee71d63e3fe070e80618938eeb522ca511ba2aaa245bf4f3c |