neft_outward

This commit is contained in:
2026-04-22 01:34:12 +05:30
commit 58d8329dbd
12 changed files with 251 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
import oracledb
from logging_config import get_logger
logger = get_logger(__name__)
# Initialize thick mode (uses Oracle Instant Client)
oracledb.init_oracle_client()
class OracleDB:
def __init__(self, config):
self.config = config
self.conn = None
def connect(self):
try:
self.conn = oracledb.connect(
user=self.config.db_user,
password=self.config.db_password,
dsn=self.config.db_dsn
)
logger.info("Connected to Oracle DB using oracledb")
except Exception as e:
logger.error("Oracle connection failed", exc_info=True)
raise
def fetch_all(self, sql):
cur = self.conn.cursor()
cur.execute(sql)
cols = [c[0] for c in cur.description]
rows = [dict(zip(cols, r)) for r in cur.fetchall()]
cur.close()
return rows
def execute(self, sql, params):
cur = self.conn.cursor()
cur.execute(sql, params)
self.conn.commit()
cur.close()