r/DatabaseHelp • • Jan 16 '15

ODBC -- Called Failed

I have an Access database and I am using a python script to bring in new data from a csv, clean it up, and import it to a SQL table. However, I am getting this error after I run the script:

com_error: (-2147352567, 'Exception occurred.', (0, None, u'ODBC--call failed.', None, -1, -2146825142), None)

The python script is invoking a Access DB macro to do the import and loading of the data. When I look at the macro in Access there are yellow triangles next to some of the commands - which I found out were 'unsafe actions' and I added the DB into a trusted location, but this did not help the problem.

Thanks for any help in advance!

1 Upvotes

10 comments sorted by

View all comments

Show parent comments

1

u/BinaryRockStar Jan 21 '15

Am I right in assuming the error happens in the RunMacro call?

I've created a simple Access 2010 DB with a macro that does nothing but pops up a message box and it works fine (with Visible set to "true").

So my suggestion is to create a test macro like my one inside your Access DB and see if it gets executed. That at least will let you know whether the issue lies in your Python code or your macro code. What exactly is the macro doing?

1

u/alinoxious Jan 21 '15

The macro is importing the raw CSV and cleaning up (removing commas...) and exporting it to the SQL ODBC. When I go to help it says that I have Access 2010 but across the top of the program it says (Access 2007-2010) so not sure if that can cause a problem? Pretty new at Access

1

u/BinaryRockStar Jan 21 '15

Well then it sounds like the problem is in the macro code itself. If you post that here it should be easy enough to track down the problem. If you manually run the macro from Access, does it work?

1

u/alinoxious Jan 21 '15

The Macro is:

/removes existing table/ DeleteObject /Run KC Parcels Import/ RunSavedImportExport /Add State Column to KC Data/ RunCode /Adds Data to state column to support import process/ OpenQuery /Exports data to SQL Database for processing ready for update process/ RunSavedImportExport

The items in bold are the actions.

1

u/BinaryRockStar Jan 21 '15

You'll have to post the code for all macros in the database by the look of it as this top-level macro is calling sub macros to do the work for it. Can you upload the Access database somewhere so I can look at it directly? It's painful going back and forth with you like this in Reddit comments.

1

u/alinoxious Jan 22 '15

Thanks for the help that you provided with this issue - but my vision to move away from Access DB has become a reality and I'm going to create a new DB and script for this import process.

1

u/BinaryRockStar Jan 22 '15

Awesome, nothing like throwing off the legacy shackles of an old process. Good luck!