From 4c63e992258b31c90e910614bdfd62908f0f761c Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Fri, 15 May 2020 08:05:04 +0200 Subject: respect syntaxe psycopg2 --- analyse/insertpaq.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'analyse') diff --git a/analyse/insertpaq.py b/analyse/insertpaq.py index 1e9a397..60d4796 100755 --- a/analyse/insertpaq.py +++ b/analyse/insertpaq.py @@ -109,12 +109,17 @@ def connexionBD(): conn=connexionBD() cur=conn.cursor() -sql=""" -insert into paquet(heure,protocole,ip_source,ip_destination,port_source,port_destination) values ('{}','{}','{}','{}','{}','{}'); -insert into paquet(heure,protocole,ip_source,ip_destination,port_source,port_destination) values ('{}','{}','{}','{}','{}','{}'); -""".format(a,b,c,e,d,f,z,y,x,v,w,u) +#sql=""" +#insert into paquet(heure,protocole,ip_source,ip_destination,port_source,port_destination) values ('{}','{}','{}','{}','{}','{}'); +#insert into paquet(heure,protocole,ip_source,ip_destination,port_source,port_destination) values ('{}','{}','{}','{}','{}','{}'); +#""".format(a,b,c,e,d,f,z,y,x,v,w,u) -cur.execute(sql) -conn.commit() +cur.execute("INSERT INTO paquet (heure,protocole,ip_source,ip_destination,port_source,port_destination) VALUES (%s, %s, %s, %s, %s, %s)", + (a, b, c, e, d, f)) +cur.execute("INSERT INTO paquet (heure,protocole,ip_source,ip_destination,port_source,port_destination) VALUES (%s, %s, %s, %s, %s, %s)", + (z, y, x, v, w, u)) + +#cur.execute(sql) +conn.commit() conn.close() -- cgit v1.2.3