[mapserver-users] asking help about python except databsaseError syntaxe

Boubacar Bah bahbouba.909 at gmail.com
Fri Sep 17 12:21:38 PDT 2021


Hi everyone
currently I am on a python script in the I am using the psycopg2 to connect
to a database
now at con = none
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.
this is my script cgi:
con = None
try:
   con = psycopg2.connect(host="localhost", database="webmapping", user=
"postgres", password=97071884)
   cur = con.cursor()
   cur.execute(
"insert into points(geom) values((SELECT ST_GeometryFromText('POINT(%s %s
)',4326)))",(coordx,coordy,))
   con.commit()
except psycopg2.DatabaseError, e:
   print("Error %s") % e
   sys.exit(1)
finally:
  if con:
     con.close()
this is my log error bellow:
[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
[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
[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
[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
if someone can suppose me idea to solve this problem
thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20210917/89fc2e66/attachment.html>


More information about the MapServer-users mailing list