-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateDB.py
28 lines (21 loc) · 937 Bytes
/
createDB.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
import sqlite3
db = sqlite3.connect("water_ch.sqlite")
# db.execute("CREATE TABLE IF NOT EXISTS water_ch (lat FLOAT, long FLOAT, canton TEXT, add_date TEXT)")
db.execute("CREATE TABLE IF NOT EXISTS water_ch "
"(id PRIMARY KEY,"
"lat_ORIGINAL TEXT, "
"long_ORIGINAL TEXT, "
"lat_DMS FLOAT, "
"long_DMS FLOAT, "
"canton TEXT, "
"add_date TEXT)")
cursor = db.cursor()
# new_data = ('12 Mar 2014', 'sunny', "20", add_date)
# cursor.execute("INSERT INTO water_ch (lat_ORIGINAL, long_ORIGINAL, add_date, canton) VALUES(?, ?, ?, ?)", new_data)
# cursor.execute("INSERT INTO water_ch (lat_ORIGINAl, long_ORIGINAL, add_date, canton) VALUES ('test', 'test', strftime('%Y-%m-%d %H:%M:%S', 'now'), 'zh')")
# cursor.execute("PRAGMA table_info(water_ch)")
for records in db.execute("SELECT * FROM water_ch"):
print(records)
cursor.close()
db.commit()
db.close()