Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. import psycopg2
  2.  
  3. try:
  4.     conn = psycopg2.connect(database = 'shop', user = 'admin1', host = "127.0.0.1", password = '1')
  5. except:
  6.     print ("I am unable to connect to the database")
  7.  
  8. cur = conn.cursor()
  9.  
  10. try:
  11.     cur.execute("""CREATE TABLE testtb(idx integer)""")
  12. except:
  13.     print ("I can't CREATE")
  14.  
  15. try:
  16.     cur.execute("""INSERT INTO testtb(idx) VALUES(1)""")
  17. except:
  18.     print ("i can't INSERT")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement