0

I have a pyodbc connection via DSN, which works fine when I run pandas read_sql:

cnxn = pyodbc.connect(DSN='address', autocommit=True)
sql = "select * from users limit 100"
df = pd.read_sql(sql, cnxn)

But when I try to use pandas to_sql, using a sqlalchemy.create engine I receive the below error:

engine = sqlalchemy.create_engine('mssql+pyodbc://username@address')    
df.to_sql('table_name', engine,if_exists='replace', index=False) 
DBAPIError: (pyodbc.Error) ('HYC00', '[HYC00] [Cloudera][ODBC] (11470) Transactions are not supported. (11470)
(SQLSetConnectAttr(SQL_ATTR_AUTOCOMMIT))') (Background on this error at: http://sqlalche.me/e/dbapi)

Has anyone had a similar issue?

Gord Thompson
  • 116,920
  • 32
  • 215
  • 418

0 Answers0