-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdb.py
99 lines (87 loc) · 2.73 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import sqlite3
conn = sqlite3.connect('database.db')
conn.execute("PRAGMA foreign_keys = 1")
print("Opened database successfully")
conn.execute('DROP TABLE IF EXISTS inventory')
conn.execute('DROP TABLE IF EXISTS issued')
conn.execute('DROP TABLE IF EXISTS issuedTo')
conn.execute('DROP TABLE IF EXISTS logindata')
conn.execute('DROP TABLE IF EXISTS policestation')
conn.execute('DROP TABLE IF EXISTS battalions')
conn.execute('DROP TABLE IF EXISTS district')
conn.execute('''CREATE TABLE IF NOT EXISTS inventory(
uniqueId INTEGER,
addedBy STRING,
productname STRING,
dateofsurvey STRING,
billno STRING,
nameoffirm STRING,
quantity STRING,
rateperitem STRING,
totalamount STRING)'''
)
conn.execute('''CREATE TABLE IF NOT EXISTS issued(
issuedBy STRING,
issuedfrom STRING,
productname STRING,
district STRING,
battalion STRING,
station STRING,
quantity STRING)'''
)
conn.execute('''CREATE TABLE IF NOT EXISTS logindata(
email STRING,
password STRING)'''
)
########### new #########
# conn.execute('''CREATE TABLE inventory
# (
# issuedfrom STRING,
# productname STRING,
# date STRING,
# dateofsurvey STRING,
# billno STRING,
# nameoffirm STRING,
# itemno STRING,
# quantity STRING,
# rateperitem STRING,
# totalamount STRING,
# crvno STRING UNIQUE)''')
#
# conn.execute('''CREATE TABLE issued
# (issuedfrom STRING,
# productname STRING ,
# battalion STRING,
# district STRING,
# policestation STRING
# quantity STRING)''')
#
#
# cur = conn.cursor()
#
#
# cur.execute('INSERT INTO logindata (email, password) VALUES (?,?)', ("[email protected]", "11111111"))
# cur.execute('INSERT INTO logindata (email, password) VALUES (?,?)', ("[email protected]", "11111111"))
#
# conn.commit()
#
# print(cur.execute("SELECT rowid, * FROM logindata").fetchall())
# print("Table created successfully")
# conn.close()
# conn.execute('''CREATE TABLE district (
# districtId INTEGER PRIMARY KEY AUTOINCREMENT,
# name STRING)''')
#
# conn.execute('''CREATE TABLE battalions (
# battalionId INTEGER PRIMARY KEY AUTOINCREMENT,
# name STRING,
# districtId INTEGER references district(districtId))''')
#
# conn.execute('''CREATE TABLE policestation (
# psId INTEGER PRIMARY KEY AUTOINCREMENT,
# psname STRING,
# districtId INTEGER references district(districtId))''')
# cur.executemany('INSERT INTO district (name) VALUES (?)', districts)
# cur.executemany('INSERT INTO battalions (name, districtId) VALUES (?,?)', battalions)
# cur.execute('INSERT INTO policestation (psname, district) VALUES (?,?)',('P.S. Sadar ',1))
# cur.execute('INSERT INTO vs (psname, district) VALUES (?,?)',('P.S. East', 'Shimla'))