MagicStack / MagicStack/asyncpg

Inserting multiple values in a row

Offen
#1,106 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
8.1k
Forks
468
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

  • asyncpg version: 0.29.0
  • PostgreSQL version: 15.4
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : No
  • Python version: 3,8,9
  • Platform: Windows 7
  • Do you use pgbouncer?: No
  • Did you install asyncpg with pip?: Yes
  • If you built asyncpg locally, which version of Cython did you use?: None
  • Can the issue be reproduced under both asyncio and
    uvloop?
    : No

Hello.
I'm migrating from psycopg2 to asyncpg and I still don't understand much and have questions.
Sorry if they are stupid :)

To fill all the cells in a row in psycopg2 I specified:

"""INSERT INTO table_name VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s);""",
                (
                    "here is a list of data"
                )

For the same operation in asyncpg I need to specify the names of all columns, i.e. the code is twice as large.
Is this the only correct solution?

"""INSERT INTO table_name
                 (
                    "here is a list of column names"
                 )
                 VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15);""",
                (
                    "here is a list of data"
                )

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Der Bericht erwähnt asyncpg, PostgreSQL 15.4, Python und eine INSERT-Anweisung, nennt jedoch weder eine Repository-Datei noch einen Test. Beginne damit, die dokumentierte Verarbeitung von INSERT-Argumenten in asyncpg zusammen mit der PostgreSQL-Syntax zu prüfen; als abgeschlossen gilt die Aufgabe erst mit einer von einem Maintainer bestätigten Antwort oder einer eng umrissenen Änderung mit einem Regressionstest.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
postgresql, python
Bereich
databases
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.