SQLAlchemy,Psycopg2和Postgresql COPY [英] SQLAlchemy, Psycopg2 and Postgresql COPY

查看:182
本文介绍了SQLAlchemy,Psycopg2和Postgresql COPY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎Psycopg具有用于执行复制的自定义命令

It looks like Psycopg has a custom command for executing a COPY:

psycopg2使用cursor.copy_from()COPY冻结大输入量

是否可以通过SQLAlchemy访问此功能?

Is there a way to access this functionality from with SQLAlchemy?

推荐答案

看起来不像

您可能只需要使用psycopg2来公开此功能并放弃ORM功能。我想我还是没有真正看到ORM在这种操作中的好处,因为它是直接的批量插入,并且在ORM中处理单个对象并没有多大意义。

You may have to just use psycopg2 to expose this functionality and forego the ORM capabilities. I guess I don't really see the benefit of ORM in such an operation anyway since it's a straight bulk insert and dealing with individual objects a la an ORM would not really make a whole lot of sense.

这篇关于SQLAlchemy,Psycopg2和Postgresql COPY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆