MagicStack / MagicStack/asyncpg
Cockroachdb copy_records_to_table support?
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 8.1k
- Forks
- 468
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
* **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)
^
```
```python
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())
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Start with asyncpg.Connection.copy_records_to_table and the generated COPY "cool_table" FROM STDIN (FORMAT binary) statement shown in the issue. Use the provided reproduction with CockroachDB and a temporary table as the acceptance case; done means the requested support works or the incompatibility and supported alternative are clearly established.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- postgresql, python
- Área
- database
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100