当前位置:网站首页>已解决(sqlalchemy+pandas.read_sql)AttributeError: ‘Engine‘ object has no attribute ‘execution_options‘
已解决(sqlalchemy+pandas.read_sql)AttributeError: ‘Engine‘ object has no attribute ‘execution_options‘
2022-07-05 03:36:00 【无 羡ღ】
成功解决( python3+sqlalchemy+pymysql 的 pandas read_sql() 方法从 MySQL 查询中读取数据报错)AttributeError: ‘Engine‘ object has no attribute ‘execution_options‘
报错代码
我的代码:
import pandas
import sqlalchemy
engine = sqlalchemy.create_engine('mssql+pymssql://用户名:密码@地址:端口号/表名')
sql = "select max(rid) as maxrid FROM student "
df = pandas.read_sql(sql=sql, con=engine)
print(df)
报错信息:
return self.connectable.execution_options().execute(*args, **kwargs)
AttributeError: 'Engine' object has no attribute 'execution_options'

报错原因
报错内容翻译:
AttributeError:“引擎”对象没有属性“execution\u options”
解决方法
传递“连接”变量而不是“引擎”
import pandas
import sqlalchemy
engine = sqlalchemy.create_engine('mssql+pymssql://用户名:密码@地址:端口号/表名')
sql = "select max(rid) as maxrid FROM student "
connection = engine.connect()
df = pandas.read_sql(sql=sql, con=connection)
print(df)
运行成功:
maxrid
0 15159049
边栏推荐
- Pdf things
- Necessary fonts for designers
- 天干地支纪年法中为什么是60年一个轮回,而不是120年
- NPM introduction link symbolic link
- [software reverse - basic knowledge] analysis method, assembly instruction architecture
- speed or tempo in classical music
- Basic function learning 02
- Installation of postman and postman interceptor
- Daily question 2 12
- Kubernetes -- cluster expansion principle
猜你喜欢

Basic knowledge of tuples

It took two nights to get Wu Enda's machine learning course certificate from Stanford University

Basic function learning 02

输入的查询SQL语句,是如何执行的?
![[luat-air105] 4.1 file system FS](/img/5e/7fdeedaef420736d761f4a681cd2d8.jpg)
[luat-air105] 4.1 file system FS

花了2晚,拿到了吴恩达@斯坦福大学的机器学习课程证书

error Couldn‘t find a package.json file in “你的路径“

【软件逆向-基础知识】分析方法、汇编指令体系结构

IronXL for .NET 2022.6

Containerization Foundation
随机推荐
New interesting test applet source code_ Test available
【无标题】
51 independent key basic experiment
Monitoring web performance with performance
Learning notes of raspberry pie 4B - IO communication (I2C)
Kubernetes -- cluster expansion principle
NEW:Devart dotConnect ADO.NET
Kubernetes - identity and authority authentication
Nmap使用手册学习记录
[groovy] loop control (number injection function implements loop | times function | upto function | downto function | step function | closure can be written outside as the final parameter)
SQL injection exercise -- sqli Labs
De debugging (set the main thread as hidden debugging to destroy the debugging Channel & debugger detection)
[untitled]
Share the newly released web application development framework based on blazor Technology
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
ICSI213/IECE213 Data Structures
汇编-入门
It took two nights to get Wu Enda's machine learning course certificate from Stanford University
NPM introduction link symbolic link
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety