MagicStack / MagicStack/asyncpg
Cockroachdb copy_records_to_table support?
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 8.1k
- 派生
- 468
- PR 合并指标
- 30 天内没有已合并 PR
描述
- asyncpg version: v0.21.0
- PostgreSQL version: CCL v20.1.8 @ 2020/10/21 15:46:38 (go1.13.9)
- Python version: 3.8
- Platform: macos
- Do you use pgbouncer?: no
- Did you install asyncpg with pip?: yes
EDIT:
Confirmed cockroachdb does not support the COPY ... FROM STDIN syntax. (https://github.com/cockroachdb/cockroach/issues/16392)
Reasoning is:
"because it's 1) complicated and 2) slow. All the data goes through a single connection. CockroachDB provides an IMPORT PGDUMP statement which is much faster and can operate in parallel."
Hopefully one of the maintainers can comment on this.
Hello, I'm not sure if this has been asked before, but I'm having issues running copy_records_to_table into a cockroachdb table/temp table. Here's a code snippet which will reproduce the issue when running a local cockroachdb.
Exception:
PostgresSyntaxError at or near "(": syntax error
DETAIL: source SQL:
COPY "cool_table" FROM STDIN (FORMAT binary)
^
import asyncio
import asyncpg
async def bwrite():
dsn = "postgres://root@localhost:26257/postgres"
conn: asyncpg.Connection = await asyncpg.connect(dsn)
await conn.execute("SET experimental_enable_temp_tables = on")
await conn.execute(
"""CREATE TEMP TABLE cool_table(
objectid int8,
CONSTRAINT "primary" PRIMARY KEY (objectid ASC)
);"""
)
try:
this_res = await conn.fetch("SHOW TABLES from pg_temp")
print(this_res)
await conn.copy_records_to_table(
"cool_table", records=[(12345,), (67890,)]
)
except Exception as e:
print(e)
if __name__ == "__main__":
# build: CCL v20.1.8 @ 2020/10/21 15:46:38 (go1.13.9)
loop = asyncio.get_event_loop()
res = loop.run_until_complete(bwrite())
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 asyncpg.Connection.copy_records_to_table 以及 issue 中显示的生成语句 COPY "cool_table" FROM STDIN (FORMAT binary) 开始。使用提供的 CockroachDB 和临时表复现作为验收用例;当所请求的支持能够正常工作,或已明确确定不兼容性及受支持的替代方案时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- postgresql, python
- 领域
- database
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100