-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_table.py
More file actions
41 lines (29 loc) · 793 Bytes
/
create_table.py
File metadata and controls
41 lines (29 loc) · 793 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import psycopg2
def create_tables():
tables =(
""" CREATE TABLE PointMachineData(
station_name varchar(255) not null
)
"""
,
""" CREATE TABLE PointMachineData_1(
station_area varchar(255) not null
)
""")
conn =None
try:
conn = psycopg2.connect(user="postgres",
password="Ankur@1998", host="127.0.0.1", port="5432",
database="Point Machine Data")
cur =conn.cursor()
for table in tables:
cur.execute(table)
cur.close()
conn.commit()
except (Exception,psycopg2.DatabaseError) as error:
print(error)
finally:
if conn is not None:
conn.close()
if __name__ == '__main__':
create_tables()