访问数据库

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]) 

posted on 2020-02-28 16:48  itprobie-菜鸟程序员  阅读(518)  评论(0编辑  收藏  举报