Python 读取 .mdb文件信息

时间:2019-06-17 15:51:05   收藏:0   阅读:1031

 

#  话不多说,码上见分晓!

使用模块: pypyodbc

例子和安装详见:

https://github.com/jiangwen365/pypyodbc/

 

#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = "loki"
import time
import pypyodbc as mdb

# 连接mdb文件
connStr = (rDriver={Microsoft Access Driver (*.mdb)};DBQ=C:\MDB_demo\demo.mdb;
           rDatabase=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

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!