(self)
| 9 | |
| 10 | class 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 | """ |
nothing calls this directly
no test coverage detected