Guest User

Untitled

a guest
Jan 8th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import psycopg2
  4.  
  5. conn = psycopg2.connect(database="testdb", user="postgres", password="pass123", host="127.0.0.1", port="5432")
  6. print "Opened database successfully"
  7.  
  8. cur = conn.cursor()
  9. cur.execute('''CREATE TABLE COMPANY
  10. (ID INT PRIMARY KEY NOT NULL,
  11. NAME TEXT NOT NULL,
  12. AGE INT NOT NULL,
  13. ADDRESS CHAR(50),
  14. SALARY REAL);''')
  15. print "Table created successfully"
  16.  
  17. conn.commit()
  18. conn.close()
Add Comment
Please, Sign In to add comment