Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
Insert an array in postgresql

I use python to connect to my postgresql database. I parse a XML fill to populate my base, so I have an array[] of values for one line to insert. I have something like this:

cur.execute("""INSERT INTO ACTIVITYDESC VALUES (%s,%s,%s,%s,%s)""",(value[0],value[1],value[2],value[3],value[4]))

There is a way to make this more simple like: ?

cur.execute("""INSERT INTO ACTIVITYDESC VALUES (%s)""",(value)) 

Thank for your help

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Turn the list into a tuple:

t = tuple(value)
cur.execute("""INSERT INTO ACTIVITYDESC VALUES %s""",(t,)) 
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!