当前位置:网站首页>已解决(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
边栏推荐
- IronXL for .NET 2022.6
- Use of kubesphere configuration set (configmap)
- Logstash、Fluentd、Fluent Bit、Vector? How to choose the appropriate open source log collector
- 汇编-入门
- Huawei MPLS experiment
- [software reverse analysis tool] disassembly and decompilation tool
- KVM virtualization
- How about programmers' eyesight| Daily anecdotes
- Anti debugging (basic principles of debugger Design & NT NP and other anti debugging principles)
- v-if VS v-show 2.0
猜你喜欢
[learning notes] month end operation -gr/ir reorganization
[web source code code code audit method] audit skills and tools
error Couldn‘t find a package.json file in “你的路径“
[C language] address book - dynamic and static implementation
ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 2)
Yuancosmic ecological panorama [2022 latest]
[web Audit - source code disclosure] obtain source code methods and use tools
[105] Baidu brain map - Online mind mapping tool
Ubantu disk expansion (VMware)
Redis source code analysis: redis cluster
随机推荐
Google Chrome CSS will not update unless the cache is cleared - Google Chrome CSS doesn't update unless clear cache
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
[wp][入门]刷弱类型题目
SPI and IIC communication protocol
特殊版:SpreadJS v15.1 VS SpreadJS v15.0
An elegant program for Euclid‘s algorithm
Pdf things
SQL performance optimization skills
LeetCode 234. Palindrome linked list
[move pictures up, down, left and right through the keyboard in JS]
面试汇总:这是一份全面&详细的Android面试指南
【做题打卡】集成每日5题分享(第三期)
What is the most effective way to convert int to string- What is the most efficient way to convert an int to a String?
IronXL for .NET 2022.6
Assembly - getting started
Zero foundation uses paddlepaddle to build lenet-5 network
Clean up PHP session files
A brief introduction to the behavior tree of unity AI
UE4 DMX和grandMA2 onPC 3.1.2.5的操作流程
Smart pointer shared_ PTR and weak_ Difference of PTR