#๐Ÿ”’ not all arguments converted during string formatting SQL

20 messages ยท Page 1 of 1 (latest)

ocean orbit
#

Will explain further in this thread ๐Ÿ™‚

latent nexusBOT
#

@ocean orbit

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

ocean orbit
#

   print(f"Aantal argumenten voor Medewerker: {len(data)}")
            print(f"Data voor Medewerker: {data}")
            cursor.execute("""
                INSERT INTO Dim_MedVraag (MedVraag4, MedVraag5, MedVraag6, MedVraag7, MedVraag8,
                                          MedVraag9, MedVraag10, MedVraag11, MedVraag12, MedVraag13,
                                          MedVraag14, MedVraag15, MedVraag16)
                VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)
                RETURNING PK_ID;
            """, data)
            medvraag_id = cursor.fetchone()[0]

            cursor.execute("""
                INSERT INTO Fact_Antwoord (FK_Locatie, FK_Periode, FK_Rol, FK_MedVraag)
                VALUES (%s, %s, %s, %s);
            """, (locatie_id, periode_id, rol_id, medvraag_id))
#

Job
Location
Period
question 4 till 15
Text

rotund forge
#

?
what does the len(data) in the first line output?

ocean orbit
#

Aantal argumenten voor Medewerker: 16

rotund forge
#

well, I count 13 %s

#

it starts at MedVraag4

ocean orbit
#

cuz i only have the questions
Job
Location
Period
seperate?

rotund forge
#

no idea what that means

#

you got 13 parameters in your query, but try to give it 16. that's three too many in your data structure.. you need to figure out why it's too many, and which ones need to be removed

shy bloom
ocean orbit
#

i am using postgres so psycopg2

shy bloom
#

ah ok

ocean orbit
#

13 yeah seems like i made a mistake there then thank you added the location and period seperate in there

#

then i know the problem ๐Ÿ™‚

#

!close

latent nexusBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.