当前位置:网站首页>已解决(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
边栏推荐
- Clickhouse同步mysql(基于物化引擎)
- When sqlacodegen generates a model, how to solve the problem that the password contains special characters?
- FBO and RBO disappeared in webgpu
- LeetCode 237. Delete nodes in the linked list
- The architect started to write a HelloWorld
- Necessary fonts for designers
- Monitoring web performance with performance
- 企业级:Spire.Office for .NET:Platinum|7.7.x
- 001 chip test
- C # use awaiter
猜你喜欢

Share the newly released web application development framework based on blazor Technology

Why do some programmers change careers before they are 30?

How to define a unified response object gracefully

An elegant program for Euclid‘s algorithm
![[数组]566. 重塑矩阵-简单](/img/3c/593156f5bde67bd56828106d7bed3c.png)
[数组]566. 重塑矩阵-简单

面试汇总:这是一份全面&详细的Android面试指南
![[groovy] string (string type variable definition | character type variable definition)](/img/d8/f02e6ad760fb039873718ff7a97b0a.jpg)
[groovy] string (string type variable definition | character type variable definition)

grandMA2 onPC 3.1.2.5的DMX参数摸索
![[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)](/img/45/6cb796364efe16d54819ac10fb7d05.jpg)
[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)

New interesting test applet source code_ Test available
随机推荐
De debugging (set the main thread as hidden debugging to destroy the debugging Channel & debugger detection)
[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)
Accuracy problem and solution of BigDecimal
Is there any way to change the height of the uinavigationbar in the storyboard without using the UINavigationController?
Google Chrome CSS will not update unless the cache is cleared - Google Chrome CSS doesn't update unless clear cache
SQL performance optimization skills
请问一下我的请求是条件更新,但在buffer中就被拦截了,这种情况我只能每次去flush缓存么?
花了2晚,拿到了吴恩达@斯坦福大学的机器学习课程证书
函数基础学习02
[groovy] string (string type variable definition | character type variable definition)
English essential vocabulary 3400
Une question est de savoir si Flink SQL CDC peut définir le parallélisme. Si le parallélisme est supérieur à 1, il y aura un problème d'ordre?
官宣!第三届云原生编程挑战赛正式启动!
[summary of two registration methods]
【web源码-代码审计方法】审计技巧及审计工具
[learning notes] month end operation -gr/ir reorganization
MindFusion.Virtual Keyboard for WPF
【软件逆向-基础知识】分析方法、汇编指令体系结构
51 independent key basic experiment
How rem is used