MCPcopy Create free account
hub / github.com/a943512/PyAibote / init_sqlite3

Method init_sqlite3

PyAibote/Tool/Sqlite3DataBase.py:11–31  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

9
10class Sqlite3DataBaseHandle(WriteReadFile):
11 def init_sqlite3(self) -> bool:
12 self.Path = f"{os.getcwd()}/ConfigFile.json"
13 if not os.path.exists(self.Path):
14 with open(self.Path,"w",encoding='UTF-8') as w:
15 w.write('')
16
17 Sqlite3_DB_Path = WriteReadFile.ReadJsonFile(self,self.Path,"Sqlite3_DB")
18
19 # 打开数据库连接
20 try:
21 self.conn = sqlite3.connect(Sqlite3_DB_Path, check_same_thread=False)
22 self.cursor = self.conn.cursor()
23 return True
24 except Exception as e:
25 print("""请在ConfigFile.json 中配置你的数据库信息示例:
26 {
27 "Sqlite3_DB":"D:\\Project\\Coding\\PyAibote\\DB\\Pyaibote.db"
28 }
29 """)
30 WriteReadFile.Custom_Write_logger(self,"",f"{os.getcwd()}/AiBotRunLOG/{time.strftime(r'%Y-%m-%d',time.localtime(time.time()))}/","SysModeError.log",False,"error",f"{traceback.format_exc()}")
31 return False
32
33 def dict_factory(self, cursor, row) -> list:
34 """

Callers

nothing calls this directly

Calls 2

ReadJsonFileMethod · 0.80
Custom_Write_loggerMethod · 0.80

Tested by

no test coverage detected