-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate_db.py
45 lines (35 loc) · 850 Bytes
/
create_db.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import sqlite3
import random
def add_num(c):
c.execute("""
SELECT COUNT(*) FROM Paths
""")
new_id = c.fetchone()[0] + 1
return new_id
def edit_database():
conn = sqlite3.connect('locations.db')
c = conn.cursor()
#c.execute("""
#CREATE TABLE Paths(
#id INTEGER PRIMARY KEY,
#road TEXT ,
#lat REAL,
#lng REAL
#);
#""")
c.execute("""
INSERT INTO Paths (id, road, lat, lng, light)
VALUES (?, ?, ?, ?, ?)
""", (add_num(c), "Ring Road", 33.64424605692703, -117.84462951054087, 1))
#c.execute("""
# DELETE FROM Paths
# WHERE id<100;
# """)
#c.execute("""
# ALTER TABLE Paths
# ADD light INTEGER;
# """)
conn.commit()
conn.close()
if __name__ == "__main__":
edit_database()