这个dataframe怎么传进数据库.一直报各种各样的错,啥都不会,期待有人能帮我一下
1条回答 默认 最新
- yuxiaqiao 2022-06-11 17:40关注
Update: starting from pandas 0.15, writing to different schema's is supported. Then you will be able to use the schema keyword argument:
df.to_sql('test', engine, schema='a_schema')
Writing to different schema's is not yet supported at the moment with the read_sql and to_sql functions (but an enhancement request has already been filed: https://github.com/pydata/pandas/issues/7441).However, you can get around for now using the object interface with PandasSQLAlchemy and providing a custom MetaData object:
meta = sqlalchemy.MetaData(engine, schema='a_schema')
meta.reflect()
pdsql = pd.io.sql.PandasSQLAlchemy(engine, meta=meta)
pdsql.to_sql(df, 'test')
Beware! This interface (PandasSQLAlchemy) is not yet really public and will still undergo changes in the next version of pandas, but this is how you can do it for pandas 0.14.Update: PandasSQLAlchemy is renamed to SQLDatabase in pandas 0.15.
解决 无用评论 打赏 举报
悬赏问题
- ¥60 求一个c语言Linux下的项目代码
- ¥15 kill GPU process : no such process
- ¥50 TF卡写入时断电数据错乱的量会是多少?
- ¥15 解释hlm多层次线性回归
- ¥115 the HDL complexity tool
- ¥15 opencv腐蚀操作
- ¥15 grbl,限位开关在触发状态,怎么进行自动复位
- ¥15 matlab无法读取mat文件,如何解决?
- ¥15 51单片机读写24C02
- ¥15 win系统下做一个开机自动最大化运行某应用程序的执行文件