generated from dopt-python/py311
add database connection tests
This commit is contained in:
42
data_analysis/02-2_connect_db.py
Normal file
42
data_analysis/02-2_connect_db.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# %%
|
||||
from pathlib import Path
|
||||
|
||||
import oracledb
|
||||
from dopt_basics import configs, io
|
||||
|
||||
# %%
|
||||
p_cfg = io.search_file_iterative(
|
||||
starting_path=Path.cwd(),
|
||||
glob_pattern="CRED*.toml",
|
||||
stop_folder_name="umbreit-py",
|
||||
)
|
||||
assert p_cfg is not None
|
||||
CFG = configs.load_toml(p_cfg)
|
||||
HOST = CFG["server"]["host"]
|
||||
PORT = CFG["server"]["port"]
|
||||
SERVICE = CFG["server"]["service"]
|
||||
USER_NAME = CFG["user"]["name"]
|
||||
USER_PASS = CFG["user"]["pass"]
|
||||
|
||||
# %%
|
||||
# !! init thick mode
|
||||
p_oracle_client = Path(r"C:\Databases\Oracle\instantclient_19_29")
|
||||
assert p_oracle_client.exists()
|
||||
assert p_oracle_client.is_dir()
|
||||
oracledb.init_oracle_client(lib_dir=str(p_oracle_client))
|
||||
# %%
|
||||
# conn = oracledb.connect(user=USER_NAME, password=USER_PASS, dsn=f"{HOST}:{PORT}/{SERVICE}")
|
||||
# conn = oracledb.connect(user=USER_NAME, password=USER_PASS, dsn=f"{HOST}/{SERVICE}")
|
||||
# conn = oracledb.connect(user=USER_NAME, password=USER_PASS, dsn="10.50.4.82:1521/TS4")
|
||||
# conn = oracledb.connect(user=USER_NAME, password=USER_PASS, dsn="ts4db:1521/?TS4")
|
||||
|
||||
# conn = oracledb.connect(user=USER_NAME, password=USER_PASS, dsn="ts4db.umbreit.local:1521/TS4")
|
||||
# conn = oracledb.connect(user=USER_NAME, password=USER_PASS, dsn="10.50.4.82:1521/TS4")
|
||||
conn = oracledb.connect(
|
||||
user=USER_NAME,
|
||||
password=USER_PASS,
|
||||
host=HOST,
|
||||
port=PORT,
|
||||
service_name="TS4",
|
||||
)
|
||||
# %%
|
||||
Reference in New Issue
Block a user