Advertisement
Guest User

Untitled

a guest
Jun 7th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. def sql_write(query, data):
  2. #is used to update or insert a new value inside a table. For reading data from the SQL table, use the sql_read function.
  3.  
  4. conn = psycopg2.connect(database="productdatabase", user="postgres",password="Welkom01",host="172.16.0.2",port="5432")
  5. cur = conn.cursor()
  6.  
  7. cur.execute(query,data)
  8. conn.commit()
  9. conn.close()
  10.  
  11.  
  12.  
  13. insertionlist = ['Cisco Catalyst Test', 1, 200, 200 , 'Test', 1,2,10000,1,'Cisco',]
  14. query= "insert into product(productnaam,product_type,aantallen,prijs,productbeschrijving,poorttypeID,aantal_poorten,serienummer,voorraadID) values (%s, %s, %s, %s, %s, %s, %s, %s, %s,)",
  15.  
  16. sql_write(query,insertionlist)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement