upload project source code
This commit is contained in:
30
后端源码/yifan.action-ai.cn/api/app/scripts/check_db_sys_menu.py
Normal file
30
后端源码/yifan.action-ai.cn/api/app/scripts/check_db_sys_menu.py
Normal file
@@ -0,0 +1,30 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import asyncio
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.core.database import async_db_session
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
async with async_db_session() as session:
|
||||
db = (await session.execute(text("SELECT DATABASE()"))).scalar()
|
||||
exists = (
|
||||
await session.execute(
|
||||
text(
|
||||
"SELECT COUNT(*) FROM information_schema.tables "
|
||||
"WHERE table_schema = DATABASE() AND table_name = 'sys_menu'"
|
||||
)
|
||||
)
|
||||
).scalar()
|
||||
|
||||
print("DATABASE() =", db)
|
||||
print("sys_menu exists count =", exists)
|
||||
if exists:
|
||||
rows = (await session.execute(text("SELECT COUNT(*) FROM sys_menu"))).scalar()
|
||||
print("sys_menu rows =", rows)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user