-
Notifications
You must be signed in to change notification settings - Fork 2
/
db_create.py
32 lines (27 loc) · 1.22 KB
/
db_create.py
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
def create_tables():
import pymysql
import config
username = config.username
password = config.password
connection = pymysql.connect(host='lake-test1.cevt7olsswvw.us-east-2.rds.amazonaws.com',
user=username,
password=password,
db='laketest')
cursor = connection.cursor()
reference_table_sql_query = "CREATE TABLE IF NOT EXISTS reference_ID(" \
"id_No INT NOT NULL AUTO_INCREMENT PRIMARY KEY," \
"lake_name TEXT," \
"source TEXT," \
"metadata JSON" \
")"
lake_water_level_query = "CREATE TABLE IF NOT EXISTS lake_water_level(" \
"id_No INT," \
"`date` DATE," \
"lake_name TEXT," \
"water_level FLOAT," \
"PRIMARY KEY (id_No, `date`)" \
")"
cursor.execute(reference_table_sql_query)
cursor.execute(lake_water_level_query)
connection.commit()
connection.close()