>>> pypyodbc.win_create_mdb('E:/Database/Japan/201112.mdb')
它适用于双级别,但是当我创建tripper级文件夹错误时出错。你能给我一个灯光>谢谢。 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.
答案 0 :(得分: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' + '"')