I'm querying Redshift with SQLAlchemy over an ODBC connection. No matter what I do, I get the following warning:
C:\Anaconda3\lib\site-packages\sqlalchemy\engine\default.py:324: SAWarning: Exception attempting to detect unicode returns: ProgrammingError("(pyodbc.ProgrammingError) ('25P02', '[25P02] [Amazon][Amazon Redshift] (30) Error occurred while trying to execute a query: [SQLState 25P02] ERROR: current transaction is aborted, commands ignored until end of transaction block\n (30) (SQLExecDirectW)')") "detect unicode returns: %r" % de)
It is not an error, just a warning. I still get the correct results. For example, simple queries like this:
from sqlalchemy import create_engine
engine = create_engine("mssql+pyodbc://@MY_CONN")
with engine.connect() as conn:
ct = conn.execute("SELECT COUNT(1) FROM my_table").scalar()
print(ct)
Will produce the correct count but still show that warning. I've done some research that indicates this might be related to autocommit options, but when I run the following code, I still get the warning, and this time with an incorrect result of 0:
ct = (
conn.execute(text("SELECT COUNT(1) FROM my_table").execution_options(autocommit=True)).scalar()
)
Besides I would think autocommit has nothing to do with read queries.
Any insights into this?
redshift+psycopg2because I can't put the login in the clear and thus I must use ODBC. Redshift and postgresql don't seem to work overpyodbcso I am just skippingsqlalchemyand usingpyodbcdirectly, which is fine for now. Anyway if you want to post your comment as an answer I will gladly accept it. Thanks again! - sparc_spread