>>> pypyodbc.win_create_mdb('E:/Database/Japan/201112.mdb')
它在双层文件夹中工作正常,但是当我创建 tripper-level 文件夹错误时出现错误。你能帮我遮一盏灯吗>谢谢。 MS Access library for python
>>> import pypyodbc
>>> pypyodbc.win_create_mdb('E:/Database/Japan/JLeague/201112.mdb')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda\lib\site-packages\pypyodbc-1.3.1-py2.7.egg\pypyodbc.py", line 2715, in win_create_mdb
raise Exception('Failed to create Access mdb file - "%s". Please check file path, permission and Access driver readiness.' %mdb_path)
Exception: Failed to create Access mdb file - "E:/Database/Japan/JLeague/201112.mdb". Please check file path, permission and Access driver readiness.
如果目录不存在,
win_create_mdb
将不会自动创建目录,因此您需要检查并可能在尝试在其中创建数据库文件之前自行创建目录。尝试这样的事情
# -*- coding: utf-8 -*-
import os
import pypyodbc
directory = 'E:/Database/Japan/J League/'
if not os.path.exists(directory):
os.makedirs(directory)
pypyodbc.win_create_mdb('"' + directory + '201112.mdb' + '"')
我是一名优秀的程序员,十分优秀!