添加注册登录功能
This commit is contained in:
47
check_user_table.py
Normal file
47
check_user_table.py
Normal file
@@ -0,0 +1,47 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
检查user表的实际结构
|
||||
"""
|
||||
from src.flask_prompt_master import create_app, db
|
||||
from sqlalchemy import inspect
|
||||
|
||||
def check_user_table():
|
||||
"""检查user表结构"""
|
||||
app = create_app()
|
||||
|
||||
with app.app_context():
|
||||
print("=" * 60)
|
||||
print("检查user表结构")
|
||||
print("=" * 60)
|
||||
|
||||
try:
|
||||
# 获取表结构
|
||||
inspector = inspect(db.engine)
|
||||
columns = inspector.get_columns('user')
|
||||
|
||||
print("📋 user表字段列表:")
|
||||
for column in columns:
|
||||
print(f" {column['name']}: {column['type']}")
|
||||
if column.get('nullable') is False:
|
||||
print(f" (NOT NULL)")
|
||||
if column.get('primary_key'):
|
||||
print(f" (PRIMARY KEY)")
|
||||
if column.get('unique'):
|
||||
print(f" (UNIQUE)")
|
||||
|
||||
# 检查是否有数据
|
||||
result = db.session.execute("SELECT COUNT(*) as count FROM user").fetchone()
|
||||
print(f"\n📊 user表记录数: {result[0]}")
|
||||
|
||||
if result[0] > 0:
|
||||
# 显示前几条记录
|
||||
print("\n📝 前3条记录:")
|
||||
records = db.session.execute("SELECT * FROM user LIMIT 3").fetchall()
|
||||
for i, record in enumerate(records, 1):
|
||||
print(f" 记录{i}: {dict(record)}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ 检查表结构失败: {str(e)}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
check_user_table()
|
||||
Reference in New Issue
Block a user