Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > db paramstyle for arrays

Thread Tools

db paramstyle for arrays

Lee Harr
Posts: n/a

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.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
Sync paramstyle between sqlite and mysql Daniel Python 3 11-11-2008 08:07 PM
curious paramstyle qmark behavior BartlebyScrivener Python 7 10-21-2006 03:27 PM
DBAPI Paramstyle Bob Parnes Python 6 03-28-2005 09:43 PM
Arrays.asList() returning java.util.Arrays$ArrayList Alexandra Stehman Java 5 06-17-2004 06:04 PM