This Python script has worked beautifully until today. I recently added a column to the table listed in the FROM clause. However, it is not the field listed in the error message.
I have also tried adding pyodbc.pooling = False to the code but that changed nothing.
I am at a loss and any help would be greatly appreciated.
# Load the needed packages
import pyodbc
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
# Define the connection parameters for MS Access
myDataSources = pyodbc.dataSources()
access_driver = myDataSources['MS Access Database']
file = '\Datasets\BookData.accdb'
# Connect to MS Access
cnxn = pyodbc.connect(Driver = access_driver, DBQ = file)
# Create a query which pulls in the correct data from MS Access
query = pd.read_sql_query('''SELECT * FROM table''', cnxn)
# Close the connection to the MS Access database
cnxn.close()
Error Message
DatabaseError: Execution failed on sql 'SELECT * FROM table': ('HY000', "[HY000] [Microsoft][ODBC Microsoft Access Driver] The specified field 'different_table.[field] could refer to more than one table listed in the FROM clause of your SQL statement. (-3007) (SQLExecDirectW)")
FROMactually a table or stored query? Try to explicitly specify columns and not use*inSELECT.