db paramstyle for arrays

Lee Harr missive at frontiernet.net
Sun Apr 4 22:57:52 EDT 2004


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.




More information about the Python-list mailing list