Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserting multiple values in a row #1106

Open
RomulBY opened this issue Nov 18, 2023 · 2 comments
Open

Inserting multiple values in a row #1106

RomulBY opened this issue Nov 18, 2023 · 2 comments

Comments

@RomulBY
Copy link

RomulBY commented Nov 18, 2023

  • 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"
                )
@elprans
Copy link
Member

elprans commented Nov 19, 2023

You don't have to specify the names of the columns with asyncpg either. What makes you think you do?

@RomulBY
Copy link
Author

RomulBY commented Nov 20, 2023

You don't have to specify the names of the columns with asyncpg either. What makes you think you do?

I tried it, but it didn't work.
Now I tried it again and it works. Perhaps I made some other mistake.
I'm very sorry, sorry for taking up your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants