mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
Update db.py
This commit is contained in:
+15
-3
@@ -42,10 +42,9 @@ class Sql():
|
||||
__debug = False
|
||||
|
||||
def __init__(self):
|
||||
self.__DB_FILE = getPanelDir()+'/data/panel.db'
|
||||
self.__DB_FILE = mw.getPanelDataDir()+'/data/panel.db'
|
||||
|
||||
def __getConn(self):
|
||||
# 取数据库对象
|
||||
def __getConnBak(self):
|
||||
try:
|
||||
if self.__DB_CONN == None:
|
||||
self.__DB_CONN = sqlite3.connect(self.__DB_FILE)
|
||||
@@ -54,6 +53,19 @@ class Sql():
|
||||
print(getTracebackInfo())
|
||||
return "error: " + str(ex)
|
||||
|
||||
def __getConn(self):
|
||||
# 取数据库对象
|
||||
if self.__DB_CONN is None:
|
||||
db_dir = os.path.dirname(self.__DB_FILE)
|
||||
if not os.path.exists(db_dir):
|
||||
os.makedirs(db_dir, exist_ok=True)
|
||||
try:
|
||||
self.__DB_CONN = sqlite3.connect(self.__DB_FILE)
|
||||
self.__DB_CONN.text_factory = str
|
||||
except Exception as ex:
|
||||
print(getTracebackInfo())
|
||||
raise
|
||||
|
||||
def changeTextFactoryToBytes(self):
|
||||
self.__DB_CONN.text_factory = bytes
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user