使用Python对Access读写操作

时间:2021-05-22

学习Python的过程中,我们会遇到Access的读写问题,这时我们可以利用win32.client模块的COM组件访问功能,通过ADODB操作Access的文件。

需要下载安装pywin32与AccessDatabaseEngine.exe

pywin32下载地址:https://puter with about 1000 - 3000 records just fine...import pprint; pp = pprint.PrettyPrinter(indent=4)columns = [column[0] for column in cursor.description]for row in cursor.fetchall(): pp.pprint(dict(zip(columns, row)))# Method 3, we obtain a list of dict's (represents the entire query)query_results = [dict(zip([column[0] for column in cursor.description], row)) for row in cursor.fetchall()]pp.pprint(query_results)# When cursor was used must be closed, if you will not use again the db connection must be closed too.cursor.close()db.close()

How to use it without install (the latest version from here)

Just copy the latest pypyodbc.py downloaded from this repository on your project folder and import the module.

Install
If you have pip available (keep in mind that the version on pypi may be old):

pip install pypyodbc

Or get the latest pypyodbc.py script from GitHub (Main Development site)

python setup.py install

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章