A new way to operate oracle
Project description
This package is a new tool to connect Oracle database.
One important thing is that I’m not the first author of this package. At the early time, this package was write by my ex-leader in 2017. And it wasn’t a package, just a python file named my_modules. Then, we modified it last year. At last she left this company, Then I refactored the code, deleted some methods uselsee.
Example
To connect:
from oracle_connection import ConnectOracle
from oracle_connection import DatabaseOperate
conn = ConnectOracle(
"your host",
"your instance name",
"your username",
"your password"
)
cursor = DatabaseOperate(conn)
# operations
cursor.close_cursor()
Get datas from database:
# ...
sql = """SELECT field1, field2 FROM table"""
# get all rows
rows = cursor.get_all(sql)
# get first row
row = cursor.get_one(sql)
# get all datas and reformat it to a dataframe
df = cursor.get_df(sql)
sql = """SELECT field FROM table"""
# get one column and reformat it to a list
row_list = cursor.one_column_list(sql)
cursor.close_cursor()
The other operations:
# ...
value1, value2, value3 = 1, 2.2, "c"
sql = """INSERT INTO table (field1, field2, field3
) VALUES (:value1, :value2, :value3)"""
# insert one row into table
cursor.execute_sql(
sql, value1=value1, value2=value2, value3=value3
)
sql = """INSERT INTO table (field1, field2, field3
) VALUES (:1, :2, :3)"""
data = [
[1, 2.2, "c"],
[2, 2.1, "d"],
[3, 4.2, "f"],
[4, 6.2, "g"]
]
# insert many rows into table
cursor.insert_data(sql, data=data)
sql = """DELETE FROM table WHERE field=:value"""
# delete datas from table
cursor.execute_sql(sql, value=value1)
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
File details
Details for the file oracle-connection-0.1.2.tar.gz
.
File metadata
- Download URL: oracle-connection-0.1.2.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
de067fd2ec250ce76d50a5c086a730090ba667d786497bbfd21df5d97bcf69d1
|
|
MD5 |
503dc1270b7bb03e94c6897e6bb77c89
|
|
BLAKE2b-256 |
8b1a139360307bf76b712c2f466421868f984951aa70fe961639666be7272199
|