Firebirdsql wrapper inspired by subprocess.run
Project description
firebirdsql-run
Firebirdsql wrapper inspired by subprocess.run
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
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
File details
Details for the file firebirdsql_run-1.1.1a0.tar.gz
.
File metadata
- Download URL: firebirdsql_run-1.1.1a0.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 | bcbc7c661bf39d1d2c980d65252d7cd3d3ac55330aab9bba5bb2fa4cb61ba018 |
|
MD5 | 05374607296383ddd0c526687e8251b0 |
|
BLAKE2b-256 | c9f084ba833bdf95b06a96ae26cd1437c670b99971598e4989ecb0cf98cf70c7 |
File details
Details for the file firebirdsql_run-1.1.1a0-py3-none-any.whl
.
File metadata
- Download URL: firebirdsql_run-1.1.1a0-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 | 4928b72e60f14eae6140730ea9400cb9709ffbf9bf31097c66c95a61061fc68a |
|
MD5 | 69fc6bde8fa090a9667a69d34afd4fa8 |
|
BLAKE2b-256 | 5a63b3444047a9fbad544fb52b869534f7bf872bdbafa7ad0c703490a9eb1349 |