python - 没有 Sql Alchemy 引擎的数据框到 sql

标签 python pandas

我有一个数据框

id    value     name
1      100       sam
2      766       abc
3      234       qqq
4      435       ppp
5      345       mmm

我想将此表保存到 sql server 数据库中的表 'tab1'

我可以执行 df.to_sql() 但是我的程序在执行此操作时挂起。(我使用的是 django)。

有没有其他方法可以在不使用 sql alchemy 引擎的情况下将数据帧保存到 sql server?

最佳答案

您可以尝试避免使用 SQL Alchemy,但 Pandas 不支持(弃用)它。

这是 pd.to_sql 文档字符串的摘录:

con : SQLAlchemy engine or DBAPI2 connection (legacy mode)

Using SQLAlchemy makes it possible to use any DB supported by that

library. If a DBAPI2 object, only sqlite3 is supported.

关于python - 没有 Sql Alchemy 引擎的数据框到 sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47979102/

相关文章:

python - 如何组合/集成存储在 3 个数据帧中的 3 个机器学习模型的结果并输出 1 个数据帧,其结果得到多数人同意?

python - 从 Pandas DataFrame 中选择日期范围

python - 为什么 "if x:"明显快于 "if x>0"?康威的人生游戏

python - 带返回值的 DataFrame 就地修改

python - python中奇怪的作用域行为

python - 安装 line_profiler 后如何修复 pip 被 proken?

python - Dict of Dict 到 CSV(带有已定义的 header )

python - 通过大量数据操作将 JSON 加速到数据帧

多个用户运行相同脚本的Python脚本

python - 如何让 Basemap 与时间片的 xarray 绘图一起使用