31 lines
833 B
Python
31 lines
833 B
Python
# -*- 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())
|
|
|