<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 10 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline;}
span.StyleCourrierlectronique17
        {font-family:Arial;
        color:windowtext;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
</head>
<body lang=FR link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>Hi and all my wishes for you
for 2007,</span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>Zope
2.8.6-final, python 2.3.5, win32, ZMySQLDA, MySQL for python.</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>In
ZMI (I know, it's not very well but I'm a newbie…), I use "Z MySQL
database connection", "Z SQL method", "Page Template",
etc, that's works fine but in "Z SQL method" I use only a simple SQL query,
like this :</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>*******************</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>select
distinct c.id_risque, c.libelle_risque, c.id_fiche, c.id_portee, c.url_info</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>from
(mots a join amotrisque b on a.id_mot = b.id_mot )</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>
</span></font><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#333333'>join risques c
on b.id_risque = c.id_risque</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>where
a.<dtml-sqltest mot_MAJ type="string" op="like"></span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>*******************</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>But
now, I need to submit a dynamic SQL query something like this:</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>*******************</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>select
distinct c.id_risque, c.libelle_risque, c.id_fiche, c.id_portee, c.url_info</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>from
(mots a join amotrisque b on a.id_mot = b.id_mot )</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>
</span></font><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#333333'>join risques c
on b.id_risque = c.id_risque</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>where
a.mot_MAJ like '%@@CRITERE1@@%'</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>union</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>select
distinct c.id_risque, c.libelle_risque, c.id_fiche, c.id_portee, c.url_info</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>from
(mots a join amotrisque b on a.id_mot = b.id_mot )</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>
</span></font><font size=2 color="#333333" face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:#333333'>join risques c
on b.id_risque = c.id_risque</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>where
a.mot_MAJ like '%@@CRITERE2@@%'</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>union</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>....</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>*******************</span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'> </span></font></p>
<p class=MsoNormal><font size=2 color="#333333" face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:#333333'>where
"%@@CRITERE1@@'" , %@@CRITERE2@@, …, are words filled
in textfield (separate by a space).</span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> </span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> </span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>1) From ONE argument, it's
possible to generate SQL dynamic request in "Z SQL method, if yes, how? (I
think that the answer is NO but I'm not sure)</span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> </span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>2) <font color=black><span
style='color:black'>I think to do that, I must to use a python script, I have a
piece of code (above) but I don't know to connect MySql database and I don't
know how to lunch my SQL query in python </span></font></span></font><font
size=2 color=black face=Wingdings><span lang=EN-GB style='font-size:10.0pt;
font-family:Wingdings;color:black'>L</span></font><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:black'> (and I suppose which I can generate a HTML results in this same
python script OR it's better to call a Page template to display results?):</span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:black'>for value in textfield.split(' '):</span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:black'> sqlquery.append("select distinct c.id_risque,
c.libelle_risque, c.id_fiche, c.id_portee, c.url_info \</span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:black'>
from (mots a join amotrisque b on a.id_mot = b.id_mot) \</span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:black'>
</span></font><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New";color:black'>join risques c
on b.id_risque = c.id_risque \</span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:black'>
where a.mot_MAJ like '%%%s%%' " % value) </span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:black'>sqlquery = " union ".join(sqlquery) </span></font></p>
<p class=MsoNormal style='text-indent:35.4pt'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";
color:black'> </span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;line-height:150%;
font-family:"Courier New";color:black'>I read many things on web, I try, but
without success, example, in ZMI, in python script object, I write this:</span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;line-height:150%;
font-family:"Courier New";color:black'># "my_base" is a "Z MySQL
database connection" </span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;line-height:150%;font-family:
"Courier New";color:black'>bd = context.my_base()</span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;line-height:150%;font-family:
"Courier New";color:black'>curs = bd.connection.cursor()</span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span style='font-size:10.0pt;line-height:150%;font-family:
"Courier New";color:black'> </span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;line-height:150%;
font-family:"Courier New";color:black'>but i get a login box ????</span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;line-height:150%;
font-family:"Courier New";color:black'> </span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;line-height:150%;
font-family:"Courier New";color:black'>How to connect a Mysql base and run my
dynamic SQL request?</span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;line-height:150%;
font-family:"Courier New";color:black'> </span></font></p>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'>Have
you an example </span></font><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'>so that I can start and
understand how this works.</span></font></p>
<p class=MsoNormal><font size=2 face="Courier New"><span lang=EN-GB
style='font-size:10.0pt;font-family:"Courier New"'> </span></font></p>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'>Thank
you very much!</span></font></p>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></font></p>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'>A desperate
French guy </span></font><font size=2 color=black face=Wingdings><span
lang=EN-GB style='font-size:10.0pt;font-family:Wingdings;color:black'>L</span></font><font
size=2 color=black face="Courier New"><span lang=EN-GB style='font-size:10.0pt;
font-family:"Courier New";color:black'> </span></font><font size=2 color=black
face=Wingdings><span lang=EN-GB style='font-size:10.0pt;font-family:Wingdings;
color:black'>L</span></font></p>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></font></p>
<p class=MsoNormal style='line-height:150%'><font size=2 color=black
face="Courier New"><span lang=EN-GB style='font-size:10.0pt;line-height:150%;
font-family:"Courier New";color:black'>Thierry</span></font></p>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></font></p>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></font></p>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></font></p>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
lang=EN-GB style='font-size:10.0pt;font-family:"Courier New";color:black'> </span></font></p>
<p class=MsoNormal><font size=2 face=Arial><span lang=EN-GB style='font-size:
10.0pt;font-family:Arial'> </span></font></p>
</div>
</body>
</html>