<div dir="ltr">Hi everyone<br>currently I am on a python script in the I am using the psycopg2 to connect to a database<br>now at con = none<br>I try to connect to my database and make an insertion in my postgis database after this request I try to manage the except in case of error; This is where the script is problematic then the day of apache error says that the except synstax has an error but after having this several times I can't find the problem. below I send you the script and error log if someone can help me solve the problem.<div>this is my script cgi:</div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre"><div>con = <span style="color:rgb(86,156,214)">None</span></div><div><span style="color:rgb(197,134,192)">try</span>:</div><div>   con = psycopg2.connect(<span style="color:rgb(156,220,254)">host</span>=<span style="color:rgb(206,145,120)">"localhost"</span>, <span style="color:rgb(156,220,254)">database</span>=<span style="color:rgb(206,145,120)">"webmapping"</span>, <span style="color:rgb(156,220,254)">user</span>=<span style="color:rgb(206,145,120)">"postgres"</span>, <span style="color:rgb(156,220,254)">password</span>=<span style="color:rgb(181,206,168)">97071884</span>)</div><div>   cur = con.cursor()</div><div>   cur.execute(<span style="color:rgb(206,145,120)">"insert into points(geom) values((SELECT ST_GeometryFromText('POINT(</span><span style="color:rgb(86,156,214)">%s</span><span style="color:rgb(206,145,120)"> </span><span style="color:rgb(86,156,214)">%s</span><span style="color:rgb(206,145,120)">)',4326)))"</span>,(coordx,coordy,))</div><div>   con.commit()</div><div><span style="color:rgb(197,134,192)">except</span> psycopg2.DatabaseError, e:</div><div>   <span style="color:rgb(220,220,170)">print</span>(<span style="color:rgb(206,145,120)">"Error </span><span style="color:rgb(86,156,214)">%s</span><span style="color:rgb(206,145,120)">"</span>) % e </div><div>   sys.exit(<span style="color:rgb(181,206,168)">1</span>)   </div><div><span style="color:rgb(197,134,192)">finally</span>:</div><div>  <span style="color:rgb(197,134,192)">if</span> con:</div><div>     con.close()</div><div>this is my log error bellow:</div><div>[Thu Sep 16 20:52:16.176534 2021] [cgi:error] [pid 2852:tid 1232] [client ::1:59242] AH01215:   File "C:\\ms4w\\Apache\\cgi-bin\\suivi_gps.cgi", line 32\r: C:/ms4w/Apache/cgi-bin/suivi_gps.cgi<br>[Thu Sep 16 20:52:16.176534 2021] [cgi:error] [pid 2852:tid 1232] [client ::1:59242] AH01215:     except psycopg2.DatabaseError, e:\r: C:/ms4w/Apache/cgi-bin/suivi_gps.cgi<br>[Thu Sep 16 20:52:16.176534 2021] [cgi:error] [pid 2852:tid 1232] [client ::1:59242] AH01215:                                  ^\r: C:/ms4w/Apache/cgi-bin/suivi_gps.cgi<br>[Thu Sep 16 20:52:16.176534 2021] [cgi:error] [pid 2852:tid 1232] [client ::1:59242] AH01215: SyntaxError: invalid syntax\r: C:/ms4w/Apache/cgi-bin/suivi_gps.cgi<br></div><div>if someone can suppose me idea to solve this problem</div><div>thanks</div></div></div></div>