API wrapper around python-oracledb to more easily perform simple database tasks.
Project description
Introduction
oraclemanager is a wrapper around python-oracledb designed to simplify repetitive database actions. It deliberately omits much of the advanced functionality of the core library in favor of a stripped down API focused on connecting, querying, commiting changes, and performing basic result transformations.
oraclemanager is ideal for applications that involve a high volume of repetitive and basic database actions. If your applications require multiple concurrent database connections, advanced scripting/querying, or high efficiency, consider using the python-oracledb library and API directly.
Installation
pip install oraclemanager
Usage
Most of the package's main functionality is exposed through the OracleManager class:
from oraclemanager import OracleManager
oracle = OracleManager()
Connecting to Databases
The connect method allows for several methods of connecting to a database. A username, password, and SID can be passed which will cause the OracleManager to attempt to connect using the EZConnect string format:
oracle.connect(username="username", password="password", sid="SID")
Alternatively, a ConnectionConfig object can be passed to the OracleManager to store credentials by SID.
config: ConnectionConfig = {
"DB1": {"username": "user1", "password": "pass123"},
"DB2": {"username": "user2", "password": "pass321"},
}
oracle = OracleManager(connection_config=config)
oracle.connect("DB1")
For connections that might not support EZConnect, a ConnectParams object can be passed.
connect_params = ConnectParams(
user="hr", password="pwd", host="dbhost", port=1521, service_name="orclpdb"
)
oracle = OracleManager()
oracle.connect(connection_params=connect_params)
Executing SQL and Accessing Query Results
The execute_sql method can be used to gather query results from SELECT statements or to execute changes to the database through INSERT or UPDATE statements.
oracle.execute_sql("select * from some_table where some_column = 'some_value'")
# Raw query results
raw_results = oracle.query_results
# Query results with data converted to strings.
results_as_strings = oracle.query_result_as_strings
# Query results with rows as ordered dictionaries.
results_as_dicts = oracle.query_result_as_dicts
# Query result column headers.
result_column_headers = oracle.query_result_column_names
Query results data formatting can be customized before conversion to strings by setting the string_formatting_options property.
formatting: StringFormattingOptions = {
"datetime_format_code": "%Y-%m-%d",
"decimal_rounding_places": 2,
}
oracle.string_formatting_options = formatting
Commiting Database Changes
oracle.execute_sql(
"update some_table t set t.some_column = 'value'
)
oracle.commit()
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oraclemanager-2.0.0.tar.gz.
File metadata
- Download URL: oraclemanager-2.0.0.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddf2c48512d7a2afe87c0e2ab59983115ea88bda6c47758faf142f1ac0500ede
|
|
| MD5 |
0c94a9dc597844f7f6aef38d3cf8f16f
|
|
| BLAKE2b-256 |
af0f78e39dcf3be00f3296e360328275fedac3d690a38374548b2e763de42f83
|
Provenance
The following attestation bundles were made for oraclemanager-2.0.0.tar.gz:
Publisher:
release.yml on ebier92/oraclemanager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oraclemanager-2.0.0.tar.gz -
Subject digest:
ddf2c48512d7a2afe87c0e2ab59983115ea88bda6c47758faf142f1ac0500ede - Sigstore transparency entry: 146255831
- Sigstore integration time:
-
Permalink:
ebier92/oraclemanager@86072923cad69a34f2aee222afe656a335e50aa2 -
Branch / Tag:
refs/heads/development - Owner: https://github.com/ebier92
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@86072923cad69a34f2aee222afe656a335e50aa2 -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file oraclemanager-2.0.0-py3-none-any.whl.
File metadata
- Download URL: oraclemanager-2.0.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53a93b34d4132fa9fa813bbfaa346e5ec68e09466854c52b0536652b5c02c732
|
|
| MD5 |
ee0f23481f3c08bb867fed4cc868c478
|
|
| BLAKE2b-256 |
6d0cb66fc9daac0668c821ba92c0edc020b6c1d17e394175c30e40170d9b326f
|
Provenance
The following attestation bundles were made for oraclemanager-2.0.0-py3-none-any.whl:
Publisher:
release.yml on ebier92/oraclemanager
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oraclemanager-2.0.0-py3-none-any.whl -
Subject digest:
53a93b34d4132fa9fa813bbfaa346e5ec68e09466854c52b0536652b5c02c732 - Sigstore transparency entry: 146255832
- Sigstore integration time:
-
Permalink:
ebier92/oraclemanager@86072923cad69a34f2aee222afe656a335e50aa2 -
Branch / Tag:
refs/heads/development - Owner: https://github.com/ebier92
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@86072923cad69a34f2aee222afe656a335e50aa2 -
Trigger Event:
workflow_run
-
Statement type: