21 lines
627 B
Python
21 lines
627 B
Python
|
|
import pymysql
|
||
|
|
|
||
|
|
conn = pymysql.connect(host='localhost', port=3306, user='root', password='rootx77', charset='utf8mb4')
|
||
|
|
cursor = conn.cursor()
|
||
|
|
|
||
|
|
cursor.execute("SHOW DATABASES LIKE 'fastadmin'")
|
||
|
|
if cursor.fetchone():
|
||
|
|
cursor.execute("USE fastadmin")
|
||
|
|
cursor.execute("SHOW TABLES")
|
||
|
|
tables = cursor.fetchall()
|
||
|
|
print(f"fastadmin 数据库有 {len(tables)} 张表")
|
||
|
|
|
||
|
|
for t in ['nf_user', 'nf_lovers', 'nf_chat_message']:
|
||
|
|
cursor.execute(f"SHOW TABLES LIKE '{t}'")
|
||
|
|
print(f"{'✅' if cursor.fetchone() else '❌'} {t}")
|
||
|
|
else:
|
||
|
|
print("fastadmin 数据库不存在")
|
||
|
|
|
||
|
|
cursor.close()
|
||
|
|
conn.close()
|