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()
Metadata
Release files for oraclemanager 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| oraclemanager-2.0.0.tar.gz | 10.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| oraclemanager-2.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.3 kB
Release files / oraclemanager-2.0.0.tar.gz
| Download URL | oraclemanager-2.0.0.tar.gz |
|---|---|
| Size | 10.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ddf2c48512d7a2afe87c0e2ab59983115ea88bda6c47758faf142f1ac0500ede
|
|
BLAKE2b-256 checksum How to use checksums |
af0f78e39dcf3be00f3296e360328275fedac3d690a38374548b2e763de42f83
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2024.
Transparency logRelease files / oraclemanager-2.0.0-py3-none-any.whl
| Download URL | oraclemanager-2.0.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53a93b34d4132fa9fa813bbfaa346e5ec68e09466854c52b0536652b5c02c732
|
|
BLAKE2b-256 checksum How to use checksums |
6d0cb66fc9daac0668c821ba92c0edc020b6c1d17e394175c30e40170d9b326f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 3, 2024.
Transparency log