SQLAlchemy、Psycopg2 和 Postgresql 复制 [英] SQLAlchemy, Psycopg2 and Postgresql COPY

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

问题描述

看起来 Psycopg 有一个自定义命令来执行 COPY:

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

使用 cursor.copy_from() 的 psycopg2 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 复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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