Dear people, I have a survey form that has about 26 fields in them and I want to put the data into a postgresql database via a psycopg adapter. Problem is when i build the insert using a zsql, do i have to manually create each field using <dtml-sqlvar ? seems very long and unproductive way to do it. Doing it using an external method, I will loose the niceties of dtml-sqlvar such as auto escaping of input and such. Suggestions anyone ? __________________________________ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail
--On Sonntag, 6. Februar 2005 7:25 Uhr -0800 Low Kian Seong <zope_low@yahoo.com> wrote:
Dear people,
I have a survey form that has about 26 fields in them and I want to put the data into a postgresql database via a psycopg adapter. Problem is when i build the insert using a zsql, do i have to manually create each field using <dtml-sqlvar ? seems very long and unproductive way to do it.
I am not completely sure but I assume that you can specify **kw as argument of a ZSQL method. So you could loop over the key-value pairs *but* you have to deal on your own *somehow* with different types (int,string, date etc.) (keep in mind that <dtml-sqlvar expects the name of an argument and its type). Depending on the database you could specify everything as 'string' but let the database to the conversion e.g. to 'int'. But at the point when you're dealing with dates or other types this approach will slap you into your face. -aj
I am assuming you are adding all fields into one table and thus would like to use one SQL query. I would create my SQL query as usual and use search replace in a text editor to add in the <dtml-sqlvar ....s. A little manual editing should not be an issue and suggest that cross check what the search replace did. Shapehead. On Sun, 6 Feb 2005 07:25:12 -0800 (PST), Low Kian Seong <zope_low@yahoo.com> wrote:
Dear people,
I have a survey form that has about 26 fields in them and I want to put the data into a postgresql database via a psycopg adapter. Problem is when i build the insert using a zsql, do i have to manually create each field using <dtml-sqlvar ? seems very long and unproductive way to do it.
Doing it using an external method, I will loose the niceties of dtml-sqlvar such as auto escaping of input and such.
Suggestions anyone ?
__________________________________ Do you Yahoo!? Yahoo! Mail - Helps protect you from nasty viruses. http://promotions.yahoo.com/new_mail _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
participants (3)
-
Andreas Jung -
Bobby Brewster -
Low Kian Seong