init database expect db_node

This commit is contained in:
Burgess Leo
2025-05-15 16:33:30 +08:00
parent c6800de871
commit 6af6fedc8e
24 changed files with 1232 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
import sqlite3
def DropAllTables(db_path):
"""
删除指定数据库中的所有8张表如果存在
:param db_path: str, SQLite 数据库文件的路径
:return: None
"""
# 表名列表根据你之前创建的8张表
tables = [
'db_config', # 表1配置表
'db_device', # 表2设备表
'db_node', # 表3节点信息表
'db_group', # 表4组表
'db_user', # 表5用户表
'db_extend_extent', # 表6扩展片段表
'db_path', # 表7路径表
'db_extend_name' # 表8扩展名表
]
# 连接到SQLite数据库
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
# 遍历并删除每张表
for table in tables:
cursor.execute(f"DROP TABLE IF EXISTS {table};")
print(f"表 [{table}] 已删除")
# 提交更改
conn.commit()
conn.close()
print("✅ 所有预定义表已删除完成")
def main():
DropAllTables(db_path='../src/db_ntfs_info.db')
if __name__ == '__main__':
main()