标签:ODB author odbc 展示 code 信息 imp exec loki
# 话不多说,码上见分晓!
使用模块: pypyodbc
例子和安装详见:
https://github.com/jiangwen365/pypyodbc/
#!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = "loki" import time import pypyodbc as mdb # 连接mdb文件 connStr = (r‘Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\MDB_demo\demo.mdb;‘ r‘Database=bill;‘ ) conn = mdb.win_connect_mdb(connStr) # connStr = ( # r‘Driver={SQL Sever};‘ # r‘Server=sqlserver;‘ # r‘Database=bill;‘ # r‘UID=sa;‘ # r‘PWD=passwd‘ # ) # # conn = mdb.connect(connStr) # 创建游标 cur = conn.cursor() cur.execute(‘SELECT * FROM bill;‘) for col in cur.description: # 展示行描述 print(col[0], col[1]) result = cur.fetchall() for row in result: # 展示个字段的值 print(row) print(row[1], row[2]
参考资料:
https://www.jianshu.com/p/00b53a386c2a
https://blog.csdn.net/jisuanjiguoba/article/details/73163721
https://www.jb51.net/article/110022.htm
https://blog.csdn.net/LIYUANNIAN/article/details/82937350
标签:ODB author odbc 展示 code 信息 imp exec loki
原文地址:https://www.cnblogs.com/Cong0ks/p/11039889.html