Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import psycopg2
- conn = psycopg2.connect(database="testdb", user="postgres", password="pass123", host="127.0.0.1", port="5432")
- print "Opened database successfully"
- cur = conn.cursor()
- cur.execute('''CREATE TABLE COMPANY
- (ID INT PRIMARY KEY NOT NULL,
- NAME TEXT NOT NULL,
- AGE INT NOT NULL,
- ADDRESS CHAR(50),
- SALARY REAL);''')
- print "Table created successfully"
- conn.commit()
- conn.close()
Add Comment
Please, Sign In to add comment