-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathdata_handling.py
44 lines (35 loc) · 908 Bytes
/
data_handling.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
import sqlite3 as sl
con = sl.connect('data.db')
# with con:
# con.execute("""
# CREATE TABLE USER (
# id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
# name TEXT,
# location TEXT,
# time TIMESTAMP DEFAULT CURRENT_TIMESTAMP
# );
# """)
# with con:
# con.execute("""
# DROP TABLE USER;
# """)
# with con:
# con.execute("""
# Delete FROM USER;
# """)
# sql = 'INSERT INTO USER (name, location) values(?, ?)'
# data = [
# ('Apoorv Mishra', 'Main Gate'),
# ('Arpit Mishra', 'Main Gate'),
# ('Mahima', 'Main Gate')
# ]
# with con:
# con.executemany(sql, data)
with con:
data = con.execute("SELECT * FROM USER")
for row in data:
print(row)
# query="UPDATE USER SET location=?, time= ? "
# data=('Hostel M', time.time())
# with con:
# con.execute(query, data)