Hi,<br><br>Have you tried Rakun Project for this problem. It supports MySQL, PostgreSQL and SQLite for now. But it can handle all kind of SQL databases.<br><br>Please take a look at its web site:<br><br><a href="http://www.rakun.org/">
http://www.rakun.org/</a><br><br>For all kind of questions about it, you can contact me<br><br><br>&gt;Content-Type: text/plain; charset=&quot;US-ASCII&quot;<br>&gt;<br>&gt;Great idea.&nbsp;&nbsp;Not to be recommended in general.<br>
&gt;<br>&gt;This works because every field is textual, and you are<br>&gt;sql-quoting by using type=string.<br>&gt;<br>&gt;Here are the problems:<br>&gt;1)&nbsp;&nbsp;if someone reads this and does not use the type=string<br>&gt;tag, or equivalent, they will be wide open to sql injection.
<br>&gt;2)&nbsp;&nbsp;OR, they can pass a list of type with each variable.<br>&gt;3)&nbsp;&nbsp;If you have to handle casts, then you will have to pass<br>&gt;a list of cast-types, as well.<br>&gt;<br>&gt;So, you have essentially moved the problem from making at
<br>&gt;least one insertion call per table to a single insertion method<br>&gt;that requires the creation of two, three, or four lists.&nbsp;&nbsp;This does<br>&gt;not self-evidently require less work.<br>&gt;<br>&gt;You can no longer inspect the method to see if it is correct.
<br>&gt;You have to look to each call-point to determine what is actually<br>&gt;being used.&nbsp;&nbsp;Just as bad, your application goes happily on its way if you<br>&gt;are missing (non-key) variables.<br>&gt;<br>&gt;Keep zsql methods a simple as possible.&nbsp;&nbsp;Use as few tricks as
<br>&gt;possible.&nbsp;&nbsp;Your goal is self-evident correctness, not the minimization<br>&gt;of typing.<br><br>&gt;jim penny<br><br><br><a href="mailto:zope-bounces@zope.org">zope-bounces@zope.org</a> wrote on 04/13/2006 02:23:22 PM:
<br><br>&gt; Whenever I'm using SQL databases in zope, I always seem to have to make<br>&gt; a ZSQL instance for inserting into every table in my database, and they<br>&gt; are all nearly the same - they just have a list of all the fields in the
<br>&gt; database in the parameters, then they say:<br>&gt;<br>&gt; insert into [table] ([list of fields]) values ([list of &lt;dtml-sqlvar&gt;s])<br>&gt;<br>&gt; I'd much rather have a dictionary of fields and values, and just throw
<br>&gt; it at the DB, not having to make those queries for every table. I have<br>&gt; acheived it like so:<br>&gt;<br>&gt; mydict = {&quot;field1&quot;:&quot;value1&quot; , &quot;field2&quot;:&quot;value2&quot; ,...}<br>
&gt; (fields,values)=zip(*myDict.items())<br>&gt; context.genericInsert(table='table name',fields=fields,values<br>=values)<br>&gt;<br>&gt; Where generic insert is the following ZSQL method:<br>&gt; insert into &quot;&lt;dtml-var table&gt;&quot;
<br>&gt;&nbsp;&nbsp;(&lt;dtml-in expr=&quot;fields&quot;&gt;&quot;&lt;dtml-var sequence-item&gt;&quot;&lt;dtml-if<br>&gt; sequence-end&gt;&lt;dtml-else&gt;,&lt;/dtml-if&gt;&lt;/dtml-in&gt;)<br>&gt;&nbsp;&nbsp;values (&lt;dtml-in expr=&quot;values&quot;&gt;&lt;dtml-sqlvar sequence-item
<br>&gt; type=string&gt;&lt;dtml-if sequence-end&gt;&lt;dtml-else&gt;,&lt;/dtml-if&gt;&lt;/dtml-in&gt;);<br>&gt;<br>&gt; with parameters:<br>&gt; * table - table name<br>&gt; * fields - list of fieldnames<br>&gt; * values - list of values in the same order
<br>&gt;<br>&gt; What do other people think of this? Is it a really bad idea?<br>&gt;<br>&gt; Robert Munro<br>&gt; _______________________________________________<br>&gt; Zope maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Zope@zope.org">Zope@zope.org
</a><br>&gt; <a href="http://mail.zope.org/mailman/listinfo/zope">http://mail.zope.org/mailman/listinfo/zope</a><br>&gt; **&nbsp;&nbsp; No cross posts or HTML encoding!&nbsp;&nbsp;**<br>&gt; (Related lists -<br>&gt;&nbsp;&nbsp;<a href="http://mail.zope.org/mailman/listinfo/zope-announce">
http://mail.zope.org/mailman/listinfo/zope-announce</a><br>&gt;&nbsp;&nbsp;<a href="http://mail.zope.org/mailman/listinfo/zope-dev">http://mail.zope.org/mailman/listinfo/zope-dev</a> )<br>&gt;<br>