question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cockroachdb copy_records_to_table support?

See original GitHub issue
  • 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 Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
cmflynncommented, Nov 5, 2020

Found the issue. I’ll look into how to put a PR up for it shortly.

0reactions
lacasaprivata2commented, Aug 31, 2021

yeah cockroach is quickly moving away from standard syntax of postgres

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support Resources | CockroachDB Docs
There are various ways to reach out for support from Cockroach Labs and our community.
Read more >
Third-Party Tools Supported by Cockroach Labs
Full support indicates that Cockroach Labs is committed to maintaining compatibility with the vast majority of the tool's features. CockroachDB is regularly ...
Read more >
CockroachDB FAQs
Choosing CockroachDB. What is CockroachDB? CockroachDB is a distributed SQL database built on a transactional and strongly-consistent key-value store.
Read more >
CockroachDB Support Policy
If your Order with Cockroach Labs specifies that you have an active subscription to Premium Support, then Cockroach Labs will provide you with...
Read more >
Common Errors and Solutions | CockroachDB Docs
Understand and resolve common error messages written to stderr or logs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found