db paramstyle for arrays

L

Lee Harr

Is there a special DB API style for inserting array values in
to a database?

In postgres, the values needs to end up like ARRAY[1, 2, 3]
so I am just putting the word ARRAY in to the query string
like this:

q = "INSERT INTO foo VALUES (ARRAY%(bar)s)" % {'bar': [1, 2, 3]}

That works, but it seems to me there may be a better way.

Thanks for your time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top