Firebirdsql wrapper inspired by subprocess.run
Project description
firebirdsql-run
Firebirdsql wrapper inspired by subprocess.run
Table of contents
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 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.1.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file firebirdsql_run-1.1.1.tar.gz
.
File metadata
- Download URL: firebirdsql_run-1.1.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5173e0a234ca4decf993f56e2493c4966e4c8c6f83921ad60eed55fd0792e226 |
|
MD5 | 576082476f81d6f0dcfa0077e1323066 |
|
BLAKE2b-256 | 865739414cea97ae1c84b2f02ed90e168429105f3de93f3eed5926eaff89d16a |
File details
Details for the file firebirdsql_run-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: firebirdsql_run-1.1.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 937a3dbea159607c9443ca879da829b115c95728c2134a88b0d4fdedc8dc79a7 |
|
MD5 | 74b3ea429df51fe428a6dcb2545bddf3 |
|
BLAKE2b-256 | 58d3d3f6fb074b4694aaf23bd0b943d89ef1ea8446fdd06377393b825e8b7c44 |