Multiple Inserts Using Sybase DAV
Hi, I'm creating a web application where users can submit and retrieve library resources online. The backend of this application is a Sybase database. I use two tables: one that stores a unique id, title, author, name, etc. And another that stores keywords related to the resource for searching purposes. All this information is captured on one form. The keywords are captured in a list by way of the Python cgi module. The problem I'm having is inserting this information into the two tables. I can easily insert the title, author, etc info into one table. But, when I try to put the keywords in a separate table, it fails. Seems like a simple task but I'm at a loss. Does anyone have any suggestions. And please also email me directly since I'm not subscribed to this list. Thank you, Kia Here is my insertAction. The appropriate parameters are in the argument list: INSERT into lib_entry ( submitter, office_num, resource_type, resource_title, resource_author, resource_pubdate, resource_abstract) VALUES ( <dtml-sqlvar submitter type="string">, <dtml-sqlvar office_num type="string">, <dtml-sqlvar resource_type type="string">, <dtml-sqlvar resource_title type="string">, <dtml-sqlvar resource_author type="string">, <dtml-sqlvar resource_pubdate type="string">, <dtml-sqlvar resource_abstract type="string">) After this, how do I insert the keywords?
<dtml-var sql_delimiter> is supposed to work with most DA. Dunno for Sybase but it works with MySQL. Workaround (no sql_delimiter) : Try a python script that calls both (or any number of) ZSQL methods in sequence providing the parameters through a dict or mapping object: context.mysqlmethod({'param1': value1, 'param2': value2}) ... ----- Original Message ----- From: "Kia A. Arab" <karab@stsci.edu> To: <zope@zope.org> Sent: Thursday, January 24, 2002 7:48 PM Subject: [Zope] Multiple Inserts Using Sybase DAV
Hi, I'm creating a web application where users can submit and retrieve library resources online. The backend of this application is a Sybase database. I use two tables: one that stores a unique id, title, author, name, etc. And another that stores keywords related to the resource for searching purposes. All this information is captured on one form. The keywords are captured in a list by way of the Python cgi module.
The problem I'm having is inserting this information into the two tables. I can easily insert the title, author, etc info into one table. But, when I try to put the keywords in a separate table, it fails.
Seems like a simple task but I'm at a loss. Does anyone have any suggestions. And please also email me directly since I'm not subscribed to this list. Thank you, Kia
Here is my insertAction. The appropriate parameters are in the argument list:
INSERT into lib_entry ( submitter, office_num, resource_type, resource_title, resource_author, resource_pubdate, resource_abstract) VALUES ( <dtml-sqlvar submitter type="string">, <dtml-sqlvar office_num type="string">, <dtml-sqlvar resource_type type="string">, <dtml-sqlvar resource_title type="string">, <dtml-sqlvar resource_author type="string">, <dtml-sqlvar resource_pubdate type="string">, <dtml-sqlvar resource_abstract type="string">)
After this, how do I insert the keywords?
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
The sql_delimiter does work with Sybase. However, the thing that is tripping me up is that the values I'm trying to get into the database are in a list. The html form is a multiple selection menu and the selections are put in a list under one name (in this case, NAME=keywords). The ACTION on my html form is a dtml-method that verifies the input, and then makes a dtml-call to a sql method. But, how do you make a dtml call to a python script and pass it a 'list' parameter? If I can pass it correctly, the Python-script would then manipulate the list and send each list value to a sql-method to insert the value in a database. Tried every which way, but not luck. I can't seem to 1 - get the values from my html form passed to a python script, then 2 - get the python script to pass the list values to a sql-method Any help is appreciated. Again, please email me directly. Thanks, K. Gilles Lenfant wrote:
<dtml-var sql_delimiter> is supposed to work with most DA. Dunno for Sybase but it works with MySQL. Workaround (no sql_delimiter) : Try a python script that calls both (or any number of) ZSQL methods in sequence providing the parameters through a dict or mapping object:
context.mysqlmethod({'param1': value1, 'param2': value2}) ...
participants (2)
-
Gilles Lenfant -
Kia A. Arab