-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeitico_db.py
75 lines (64 loc) · 1.31 KB
/
feitico_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
import sqlite3
import os
PATH = os.path.join(os.getcwd(), 'resources', 'feitico.db')
conn = sqlite3.connect(PATH)
cursor = conn.cursor()
###################
# CRIANDO TABELAS #
###################
# cursor.execute("""
# CREATE TABLE feitico (
# id_feitico INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
# nome VARCHAR(255) NOT NULL UNIQUE,
# descricao TEXT NOT NULL,
# disponivel BOOLEAN NOT NULL,
# nivel INTEGER NOT NULL,
# dificuldade INTEGER NOT NULL,
# tipo INTEGER NOT NULL,
# ex_solucao TEXT
# );
# """)
# cursor.execute("""
# CREATE TABLE status (
# id_status INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
# id_feitico INTEGER,
# assunto VARCHAR(255) NOT NULL,
# valor INTEGER NOT NULL,
# FOREIGN KEY(id_feitico) REFERENCES feitico(id_feitico)
# );
# """)
# ADICIONANDO CAMPO NA TABELA
# cursor.execute("""
# ALTER TABLE feitico ADD COLUMN json TEXT;
# """)
#####################
# INSERINDO VALORES #
#####################
# cursor.execute("""
# INSERT INTO feitico VALUES (
# null,
# 'teste',
# 'feitico que ordena livros',
# 1,
# 0,
# 0,
# 1,
# null
# );
# """)
# cursor.execute("""
# INSERT INTO status VALUES (
# null,
# 4,
# 'operadores',
# 90
# );
# """)
conn.commit()
cursor.execute("""
SELECT * FROM status
WHERE assunto = 'tipos'
and id_feitico > 2
""")
print cursor.fetchall()
conn.close()