[Zope] Dynamic SQL problems.

AM list_subscriber@neurobs.com
Thu, 16 Jan 2003 10:00:53 -0800


When you say format do you mean the underlying physical format ( as in 
InnoDB/ BDB etc ) or do you mean just the column names.

If it is the former then there  usually you can use the SHOW command to 
get details about the table ( I only know about MySQL, but PG is way 
ahead of MySQL in terms of features and it should be there ).

If it is the latter the same using SHOW COLUMNS will get you the list of 
columns. You can always use DTML in a ZSQL query to read off a 
dictionary of key value pairs.

So IMO use a ZSQL which does something like this:

insert into <table> (
  <dtml-in <var_name>.keys>
    <dtml-var sequence-item>  <dtml-if "not _['sequence-end']">,</dtml-if>
  </dtml-in> )
values (
  <dtml-in <var_name>.values>
    <dtml-var sequence-item>  <dtml-if "not _['sequence-end']">,</dtml-if>
  </dtml-in> )

I think that should do what you want.

to get the dictionary the easiest way is to process the input form in a 
python script that creates a dictionary from the form vars.

hth
am

Daniel Jackson wrote:

>I'm trying to create a dynamic table editor. The idea is you instance
>this product, give it the database host, user, pass, database name
>(Postgres in this case, BTW), and table, and you can edit that table via
>a nifty web interface. The problem is, I don't know what this table's
>format is beforehand, so I can't realy make any ZSQL methods for
>inserting new rows. Does anyone know how to work around this? 
>
>Thanks, DJ.
>
>
>
>
>_______________________________________________
>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 )
>
>
>  
>

-- 
==================================================================
 Aseem Mohanty							   
 Neurobehavioral Systems Inc, 828 San Pablo Ave, Albany, CA 94706 
 (R) 510 7696011 (M) 510 3014871 (O) 510 5279231		  	
==================================================================								  	
 "I saw `cout' being shifted "Hello world" times to the left and  
  stopped right there!!"                        -- Steve Gonedes  
==================================================================