Files
AILab/bbit_ai/test/other/sqlserver.py
T
2025-11-05 18:08:28 +08:00

8 lines
367 B
Python

from sqlalchemy import create_engine, text # ✅ 注意这里导入 text
uri = "mssql+pyodbc://f8_db_test:APN^QPr!K9@122.114.58.23/f8_db_test?driver=ODBC+Driver+18+for+SQL+Server&TrustServerCertificate=yes"
engine = create_engine(uri)
with engine.connect() as conn:
result = conn.execute(text("SELECT count(*) FROM dbo.NONGHU_INFO"))
print(result.scalar())