From: Paul Zwarts <paul.zwarts@oratrix.com> > ValueError: PQsendQuery() -- query is too long. Maximum length is 16382 This is purely a PostgreSQL issue; Some (all? not sure.) versions of PostgreSQL have a hard limit on the length of query strings. You have to break your query into multiple smaller queries. Cheers, Evan @ digicool & 4-am