# Oracle Select
An easy interface for reading from an Oracle database with cx_Oracle.
## To use:
Usage is meant to be simple. Provide your username, password, and host address when you instantiate the DB class. Each select statement opens and closes a new connection. Results are returned as lists of dicts or an empty list if no results are found. For each result, any LOB-like fields are read into strings/bytes for easy handling.
>>> from oracle_select import DB >>> db = DB(username='your.username', password='password', host='DBNAME.WORLD') >>> sql = """select * from ps_table""" >>> db.select(sql)
### Using bind variables
Bind variables can be passed to the select statement in two ways:
As a dictionary when referencing named sql variables:
>>> sql = """select * from ps_table where emplid = :emplid"""
>>> db.select(sql, binds={'emplid': '12345678'})
Or as a tuple when referencing numeric sql variables:
>>> sql = """select * from ps_table where emplid = :1"""
>>> db.select(sql, binds=('12345678',))
### Fetch One vs. Many vs. All
By default all results will be returned. Sometimes, when the result set is large, this is a bad idea. To limit your result set, modify the fetch parameter. Then the select statement will only return N results.
>>> sql = """select * from ps_table""" >>> db.select(sql, fetch=10) # fetch first ten results >>> db.select(sql, fetch=0) # fetch all results (default)
### Fetch Large Datasets with a Generator
Large datasets can be retrieved using the select_iter method:
>>> sql = """select * from ps_large_table""" >>> for chunk in db.select_iter(sql): >>> for result in chunk: >>> print(result)
Results will be returned in chunks of fetch_size. To limit the total number of results, set max_rows. By default chunks of 1,000 records will be returned until the entire result set has been consumed (max_rows = None).
## Utils
The oracle_select.utils module provides some useful tools for working with PeopleSoft, including an interface for polling the process monitor.
Release files for oracle-select 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| oracle_select-0.1.3.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| oracle_select-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.7 kB
Release files / oracle_select-0.1.3.tar.gz
| Download URL | oracle_select-0.1.3.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
02ef6053f905d3d6afc41bd2c3e4f13458ee249ff14d0f20c33370b6d9509a46
|
|
BLAKE2b-256 checksum How to use checksums |
a71499426493de6f72c4cfe1bce679db94958047f913decbc9525c4fe75e9c2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.20.1 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|
Release files / oracle_select-0.1.3-py3-none-any.whl
| Download URL | oracle_select-0.1.3-py3-none-any.whl |
|---|---|
| Size | 3.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8733f7ec305d06a65bdc4380750fff5cec8d55517bd5b76e5d9615cb4a37cfec
|
|
BLAKE2b-256 checksum How to use checksums |
469db63ea968fd110ad7df491758f7efbab487ca8ff689f867d25ebd8ce17e7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.20.1 setuptools/41.0.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
|