MagicStack / MagicStack/asyncpg
Cockroachdb copy_records_to_table support?
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 8.1k
- Forks
- 469
- Ø Merge
- 18 Min.
- Gemergte PRs (30 T.)
- 4
Beschreibung
- 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())
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit asyncpg.Connection.copy_records_to_table und der im Issue gezeigten generierten COPY "cool_table" FROM STDIN (FORMAT binary)-Anweisung. Verwende die bereitgestellte Reproduktion mit CockroachDB und einer temporären Tabelle als Abnahmekriterium; abgeschlossen bedeutet, dass die angeforderte Unterstützung funktioniert oder die Inkompatibilität und die unterstützte Alternative eindeutig festgestellt sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- postgresql, python
- Bereich
- database
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100