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(q"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.
This object contains the following attributes:
host
: The host address of the server.port
: The port number of the server.db
: The database where the transaction was executed.user
: The user who executed the transaction.access
: The access mode used for the transaction.returncode
: The return code of the transaction execution.exception
: The exception message if the transaction failed.query
: The SQL query executed in the transaction.params
: The parameters used in the SQL query.time
: The number of seconds it took to execute the transaction.data
: The data returned by the transaction, represented as a list of dictionaries.
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.0a0.tar.gz
.
File metadata
- Download URL: firebirdsql_run-1.1.0a0.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cf4d70eda7a2be325438d53556ff4e7b8aa9551b54f54b7129aafb5c49f6379 |
|
MD5 | faf58217005902b88058e3891b182ba4 |
|
BLAKE2b-256 | fc99f1bbd47d440f578237afd5ef7028ed5d43a47ece334c83590894ff6dfa7a |
File details
Details for the file firebirdsql_run-1.1.0a0-py3-none-any.whl
.
File metadata
- Download URL: firebirdsql_run-1.1.0a0-py3-none-any.whl
- Upload date:
- Size: 6.6 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 | caf78eb460568395983c797eb189edf4b5501f15df16117bed58e5f0bfdb0a61 |
|
MD5 | f7a0d6e84ca7818df7fd76887fe2a219 |
|
BLAKE2b-256 | 15e42fb238f1213ded8ee8fe465c7b28f1230ae619e27f766e827f8407893a04 |