当前位置:网站首页>Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘

Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘

2022-07-05 03:49:00 No envy

Successfully solved ( python3+sqlalchemy+pymysql Of pandas read_sql() Methods from MySQL Error in reading data in query )AttributeError: ‘Engine‘ object has no attribute ‘execution_options‘







Error code


My code :

import pandas
import sqlalchemy

engine = sqlalchemy.create_engine('mssql+pymssql:// user name : password @ Address : Port number / Table name ')
sql = "select max(rid) as maxrid FROM student "
df = pandas.read_sql(sql=sql, con=engine)
print(df)

Error message :

    return self.connectable.execution_options().execute(*args, **kwargs)
AttributeError: 'Engine' object has no attribute 'execution_options'

 Insert picture description here



Error reason


Translation of error reporting content :

AttributeError:“ engine ” Object has no properties “execution\u options” 


resolvent


Pass on “ Connect ” Variables, not “ engine ”

import pandas
import sqlalchemy

engine = sqlalchemy.create_engine('mssql+pymssql:// user name : password @ Address : Port number / Table name ')
sql = "select max(rid) as maxrid FROM student "
connection = engine.connect()
df = pandas.read_sql(sql=sql, con=connection)
print(df)

The successful running :

     maxrid
0  15159049
原网站

版权声明
本文为[No envy]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207050336151515.html