2
>>> pypyodbc.win_create_mdb('E:/Database/Japan/201112.mdb')

它对于双级工作正常,但是当我创建跳闸级文件夹错误时出现错误。你能给我遮光吗> 谢谢。 用于 python 的 MS Access 库

>>> 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.
4

1 回答 1

3

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' + '"')
于 2014-03-22T21:25:33.200 回答