2

I've installed pypyodbc to create and modify Access Databases. However, following the tutorials I am getting the following error:

Traceback (most recent call last):
  File "<pyshell#15>", line 1, in <module>
    pypyodbc.win_create_mdb('C:\\database.mdb')
  File "C:\Python33\lib\site-packages\pypyodbc-1.3.0-py3.3.egg\pypyodbc.py", line 2713, 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 - "C:\database.mdb". Please check file path, permission and Access driver readiness.

all I am doing is:

import pypyodbc
pypyodbc.win_create_mdb('C:\\databases\\database.mdb')

I have been searching for an answer but this error normally occurs with Linux it seems not Windows.

I am using ActivePython3.3 (32-bit), pypyodbc, MS Access 2010 (32-bit) on Windows 7 (administrator access).

SOLVED:

By importing the os module and finding the filepath, then using that filepath as the parameter in the above statement.

Thank you for your help. Unfortunately I seem to be having problems where the links to answer, comment etc don't work I also can't seem to rate answers either.

user2862873
  • 41
  • 1
  • 4

1 Answers1

0

You are trying to create the database file in the root folder of the system drive (C:\). That folder has restricted permissions so ordinary users cannot create files there. Try changing the path to one where you actually have permission to create files, e.g.,

import pypyodbc
pypyodbc.win_create_mdb('C:\\Users\\Public\\database.mdb')
Gord Thompson
  • 116,920
  • 32
  • 215
  • 418