Created
January 8, 2019 02:44
-
-
Save Xifeng2009/6d2ca26a2d3a42554f1a7670f9db82d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment