[Zope] How can you generalize SQL methods ?

Marco Guidi GUIDI@sssup.it
Wed, 14 Jul 1999 10:04:58 +0200


Hi I've the following problem:

I'd like to have in my "root" folder some general SQL (mysql) methods
so that I can call them from the subfolders.

I insert  here 2 examples of what I'd like to do.


1- Creating a general INSERT query.

    I tried to create a query resembling the following:

INSERT INTO <!--#var table_name-->
  (<!--#var field_name-->) values
    (<!--#sqlvar field_value type=<!--#var field_type--> -->)

  where field table_name, field_name, field_value and field_type are 
arguments
  for the methon. Naturally this doesn't work. Is there any way to do 
something
  like this ?

2- creating a general SELECT query.

   I'd like to parametrize the name and the number of the fields shown
   by a SELECT mysql query. Something like

   SELECT <variable_number_of_fields_of_variable_names> from
     <!--#var table_name-->

   where table_name is an argument for the method.
   I've no ideas about how to implement the
   variable_number_of_fields_of_variable_names.

Is there anyone who can help me (eventually source code examples or
links to them will be welcome).

   Thank you in advance.

Marco Guidi

e-mail: guidi@sssup.it