customs-data / check_db.py
3v324v23's picture
refactor(check_db): 简化并重构数据库检查脚本
899889d
Raw
History Blame Contribute Delete
657 Bytes
import asyncio
from packages.core.database import AsyncSessionLocal
from sqlalchemy import text
async def main():
async with AsyncSessionLocal() as session:
r = await session.execute(text("select hs_code, product_name, origin_country, destination_country, departure_port, arrival_port, transport_mode from standard_trade_records limit 5"))
for row in r:
print(f"HS: {row[0]}")
print(f"Product: {row[1]}")
print(f"Origin -> Dest: {row[2]} -> {row[3]}")
print(f"Port Dep -> Arr: {row[4]} -> {row[5]}")
print(f"Transport: {row[6]}")
print("---")
asyncio.run(main())