-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.pyw
60 lines (48 loc) · 1.49 KB
/
main.pyw
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
"""
Save auto repair notes.
Created on 25.05.2017
@author: Ruslan Dolovanyuk
"""
import sqlite3
from drawer import Drawer
def setup(conn, cursor):
"""Create table in database."""
script = '''CREATE TABLE window (
id INTEGER PRIMARY KEY NOT NULL,
px INTEGER NOT NULL,
py INTEGER NOT NULL,
sx INTEGER NOT NULL,
sy INTEGER NOT NULL) WITHOUT ROWID
'''
cursor.execute(script)
script = '''INSERT INTO window (id, px, py, sx, sy)
VALUES (1, 0, 0, 800, 600)'''
cursor.execute(script)
script = '''CREATE TABLE category (
id INTEGER PRIMARY KEY NOT NULL,
name TEXT NOT NULL) WITHOUT ROWID
'''
cursor.execute(script)
script = '''CREATE TABLE main (
id INTEGER PRIMARY KEY NOT NULL,
title TEXT NOT NULL,
date TEXT NOT NULL,
company TEXT,
model TEXT,
serial TEXT,
data TEXT,
category INTEGER NOT NULL) WITHOUT ROWID
'''
cursor.execute(script)
conn.commit()
if __name__ == '__main__':
conn = sqlite3.connect('autonotes.db')
cursor = conn.cursor()
str_sql = 'SELECT * FROM sqlite_master WHERE name = "main"'
cursor.execute(str_sql)
if not cursor.fetchone():
setup(conn, cursor)
drawer = Drawer(conn, cursor)
drawer.mainloop()
cursor.close()
conn.close()