Python 读取 .mdb文件信息
时间:2021-07-01 10:21:17
帮助过:29人阅读
!/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
Python 读取 .mdb文件信息
标签:ODB author odbc 展示 code 信息 imp exec loki