sqlalchemy-access: Table already exists

298 Views Asked by At

Update: I tried running the script from another computer with an earlier version of sqlalchemy-access (1.1.2 instead of 1.1.3) the script worked. When I installed 1.1.2 on the computer that gave the error, I got

NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:access.pyodbc

Both computers are updating the same access table (which is saved on a network drive).


I am updating an existing MS Access table using a dataframe (all_results_df):

cnn_str = r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\data\MyData.accdb;'
cnn_url = f"access+pyodbc:///?odbc_connect={urllib.parse.quote_plus(cnn_str)}"
acc_engine = create_engine(cnn_url)
all_results_df.to_sql('results', acc_engine, if_exists='append')

and I get the following error:

ProgrammingError: ('42S01', "[42S01] [Microsoft][ODBC Microsoft Access Driver] Table 'results' already exists. (-1303) (SQLExecDirectW)")

Why doesn't it just append the new data to the existing table?

1

There are 1 best solutions below

0
Nitzan On

Eventually, updating ms-access solved the problem.