I Implemented following Query By SQLAlchemy in Python:
url = URL.create(
drivername="access+pyodbc",
query={
"odbc_connect": connStr,
},
)
with create_engine(url).connect() as con:
sql_get_anag = text(f"SELECT Tipo_Presenza FROM Presenza WHERE ID_Anagrafica = {IDValue} AND Giorno > {current_day_insert} AND Giorno < {current_day_insert_1}")
Presenza_tab = pd.read_sql_query(sql_get_anag, con)
This return following error:
Exception has occurred: ProgrammingError
(pyodbc.ProgrammingError) ('42000', "[42000] [Microsoft][Driver ODBC Microsoft Access] Errore di sintassi (operatore mancante) nell'espressione della query 'ID_Anagrafica = 4 AND Giorno > 24-05-24 00:00:00 AND Giorno < 25-05-24 00:00:00'. (-3100) (SQLExecDirectW)")
[SQL: SELECT Tipo_Presenza FROM Presenza WHERE ID_Anagrafica = 4 AND Giorno > 24-05-24 00:00:00 AND Giorno < 25-05-24 00:00:00]
(Background on this error at: https://sqlalche.me/e/20/f405)
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][Driver ODBC Microsoft Access] Errore di sintassi (operatore mancante) nell'espressione della query 'ID_Anagrafica = 4 AND Giorno > 24-05-24 00:00:00 AND Giorno < 25-05-24 00:00:00'. (-3100) (SQLExecDirectW)")
In my opinion is the Date syntax for where condition that is not correct, but I don’t know what is the correct syntax.
Have you suggestion about this problem?
Thank you
Mario
I tried to add and remove the ‘ on the date parameters but without success.
My expectation is to make the select query correctly
Thanks
1