访问数据库
cnxn = pyodbc.connect("Driver={SQL Server};Server=localhost;Database=用户名;uid=sa;pwd=密码")
cursor = cnxn.cursor()
cursor.execute("select * from config where type_id='gh_zhjy'")
users=[]
for row in cursor:
users.append(row[3])
print(user[0])
cnxn = pyodbc.connect("Driver={SQL Server};Server=localhost;Database=reportdb_nh;uid=sa;pwd=GHND@126.com")
cursor = cnxn.cursor()
cursor.execute("select * from config where type_id='gh_zhjy'")
users=[]
for row in cursor:
users.append(row[3])
来源:https://www.cnblogs.com/guohu/p/12377898.html