Initial commit
This commit is contained in:
0
aore/dbutils/__init__.py
Normal file
0
aore/dbutils/__init__.py
Normal file
33
aore/dbutils/dbimpl.py
Normal file
33
aore/dbutils/dbimpl.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
class DBImpl:
|
||||
def __init__(self, engine, params):
|
||||
self.db_engine = engine
|
||||
self.connection = engine.connect(**params)
|
||||
|
||||
def transaction_commit(self):
|
||||
self.connection.commit()
|
||||
|
||||
def transaction_rollback(self):
|
||||
self.connection.rollback()
|
||||
|
||||
def close(self):
|
||||
if self.connection:
|
||||
self.connection.close()
|
||||
|
||||
def get_cursor(self):
|
||||
return self.connection.cursor()
|
||||
|
||||
def get_rows(self, query_string, for_dict=True):
|
||||
if for_dict:
|
||||
cur = self.connection.cursor(self.db_engine.cursors.DictCursor)
|
||||
else:
|
||||
cur = self.connection.cursor()
|
||||
cur.execute(query_string)
|
||||
|
||||
rows = cur.fetchall()
|
||||
if cur:
|
||||
cur.close()
|
||||
|
||||
return rows
|
||||
18
aore/dbutils/dbschemas.py
Normal file
18
aore/dbutils/dbschemas.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
class DbSchema:
|
||||
def __init__(self, name, fieldlist, xmltag):
|
||||
self.tablename = name
|
||||
self.fields = fieldlist
|
||||
self.xml_tag = xmltag
|
||||
|
||||
|
||||
db_shemas = dict()
|
||||
db_shemas['ADDROBJ'] = DbSchema("ADDROBJ",
|
||||
["AOID", "AOGUID", "SHORTNAME", "FORMALNAME", "AOLEVEL", "PARENTGUID", "ACTSTATUS",
|
||||
"CURRSTATUS"],
|
||||
"Object")
|
||||
db_shemas['SOCRBASE'] = DbSchema("SOCRBASE", ["LEVEL", "SOCRNAME", "SCNAME", "KOD_T_ST"], "AddressObjectType")
|
||||
|
||||
allowed_tables = ["ADDROBJ", "SOCRBASE"]
|
||||
Reference in New Issue
Block a user