I have a database with huge tables. Loading and processing them via pyodbc is taking ages, so no option.
Currently I am manually exporting my updated tables from MS Access into a .csv and then loading them into python.
Now I want to automate this process via python. I have seen a similar problem here
My code:
import os
import win32com.client
current_PATH = os.getcwd()
db_PATH = current_PATH+"\\database.accdb;"
oApp = win32com.client.Dispatch("Access.Application")
oApp.OpenCurrentDatabase(db_PATH)
acExportDelim = 2
oApp.DoCmd.TransferText(acExportDelim, None, "table_to_export", 'Output.csv', True)
oApp.DoCmd.CloseDatabase
oApp.Quit
oApp = None
But all I get in response is:
Traceback (most recent call last):
File "C:\Users\...\export_script.py", line 9, in <module>
oApp.OpenCurrentDatabase(db_PATH)
File "<COMObject Access.Application>", line 3, in OpenCurrentDatabase
File "C:\Anaconda3\lib\site-packages\win32com\client\dynamic.py", line 282, in _ApplyTypes_
result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)
[Finished in 6.9s with exit code 1]
What is the correct way to export a table to a .csv?
Edit: That is how my test table looks like: test_table