Initial commit: 微信联系人祝福管理系统
This commit is contained in:
28
add_column.py
Normal file
28
add_column.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""添加 custom_content 和 search_name 字段"""
|
||||
import sqlite3
|
||||
|
||||
DB_PATH = r"D:\夏骥\微信研究\contacts.db"
|
||||
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 检查字段是否已存在
|
||||
cursor.execute("PRAGMA table_info(contacts)")
|
||||
columns = [col[1] for col in cursor.fetchall()]
|
||||
|
||||
if 'custom_content' not in columns:
|
||||
cursor.execute('ALTER TABLE contacts ADD COLUMN custom_content TEXT DEFAULT ""')
|
||||
print("已添加 custom_content 字段")
|
||||
else:
|
||||
print("custom_content 字段已存在")
|
||||
|
||||
if 'search_name' not in columns:
|
||||
cursor.execute('ALTER TABLE contacts ADD COLUMN search_name TEXT DEFAULT ""')
|
||||
print("已添加 search_name 字段")
|
||||
else:
|
||||
print("search_name 字段已存在")
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
print("完成")
|
||||
Reference in New Issue
Block a user