# -*- conding: utf-8 -*-
import pypyodbc
if __name__=="__main__":
str = 'Driver={Microsoft Access Driver (*.mdb)}DBQ=E:\\123.mdb'
conn = pypyodbc.win_connect_mdb(str)
#conn = pypyodbc.connect(str)
cur = conn.cursor()
cur.execute("SELECT * FROM catalog")
for row in cur.fetchall():
for field in row:
print field,
print ''
conn.commit()
cur.close()
conn.close()
import pyodbcdbfile="db2.mdb"
try:
conn=pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)}PWD=thepwdDBQ='+dbfile)
cur=conn.cursor()
cur.execute("select * from standard")
print cur.fetchone()
print dir(cur)
except pyodbc.Error,e:
print e[1]
except pyodbc.ProgrammingError,e:
print e[1]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)