mirror of
https://github.com/hoshikawa2/rfp_response_automation.git
synced 2026-03-06 10:11:08 +00:00
first commit
This commit is contained in:
50
files/modules/users/db.py
Normal file
50
files/modules/users/db.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
import oracledb
|
||||
import json
|
||||
import base64
|
||||
import hashlib
|
||||
from datetime import datetime
|
||||
import requests
|
||||
import textwrap
|
||||
import unicodedata
|
||||
from typing import Optional
|
||||
from collections import deque
|
||||
from config_loader import load_config
|
||||
|
||||
def chunk_hash(text: str) -> str:
|
||||
return hashlib.sha256(text.encode("utf-8")).hexdigest()
|
||||
|
||||
config = load_config()
|
||||
|
||||
# =========================
|
||||
# Oracle Autonomous Configuration
|
||||
# =========================
|
||||
WALLET_PATH = config.wallet_path
|
||||
DB_ALIAS = config.db_alias
|
||||
USERNAME = config.username
|
||||
PASSWORD = config.password
|
||||
os.environ["TNS_ADMIN"] = WALLET_PATH
|
||||
|
||||
_pool = None
|
||||
|
||||
def get_pool():
|
||||
global _pool
|
||||
|
||||
if _pool:
|
||||
return _pool
|
||||
|
||||
_pool = oracledb.create_pool(
|
||||
user=USERNAME,
|
||||
password=PASSWORD,
|
||||
dsn=DB_ALIAS,
|
||||
config_dir=WALLET_PATH,
|
||||
wallet_location=WALLET_PATH,
|
||||
wallet_password=PASSWORD,
|
||||
min=2,
|
||||
max=8,
|
||||
increment=1
|
||||
)
|
||||
|
||||
return _pool
|
||||
Reference in New Issue
Block a user