-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb_create.py
40 lines (30 loc) · 1.11 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
32
33
34
35
36
37
38
39
40
import sqlite3
from _config import DATABASE_PATH
with sqlite3.connect(DATABASE_PATH) as connection:
# get a cursor object used to execute SQL commands
c = connection.cursor()
# create the table
c.execute("""CREATE TABLE air_pollution(air_value_id INTEGER PRIMARY KEY
AUTOINCREMENT,
air_value INTEGER NOT NULL, text_value TEXT NOT NULL, updated_at TEXT NOT NULL, scraped_at
TEXT NOT NULL)""")
# insert dummy data into the table
c.execute(
'INSERT INTO air_pollution (air_value, text_value, updated_at, scraped_at)'
'VALUES(57, "Moderate", "Updated on Monday 16:00", "2016-12-12")'
)
c.close()
# x = 1000
# y = 0
# while(x > y):
# from _config import DATABASE_PATH
# with sqlite3.connect(DATABASE_PATH) as connection:
# # get a cursor object used to execute SQL commands
# c = connection.cursor()
# c.execute(
# 'INSERT INTO air_pollution (air_value, text_value, updated_at, scraped_at)'
# 'VALUES(57, "Moderate", "Updated on Monday 16:00", "2016-12-12")'
# )
# y += 1
# print(y)
# c.close()