I have a Python script that runs a pgSQL file through the SQLAlchemy connection.execute function. Here's the code block in Python:
results = pg_conn.execute(sql_cmd, beg_date = datetime.date(2015,4,1), end_date = datetime.date(2015,4,30))
And here is one of the areas where a variable is introduced into my SQL:
WHERE
( dv.date >= %(beg_date)s AND
dv.date <= %(end_date)s)
When I run this, I get a cryptic python error:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) argument formats can't be mixed
... followed by a huge dump of abusive SQL query. I ran this exact code with the same legend. Why doesn't it work this time?
source
share