-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabaser.py
More file actions
36 lines (32 loc) · 837 Bytes
/
databaser.py
File metadata and controls
36 lines (32 loc) · 837 Bytes
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
import sqlite3
conn = sqlite3.connect('devall.db')
cursor = conn.cursor()
cursor.execute("""
create table if not exists votacoes(
titulo VARCHAR(80) NOT NULL PRIMARY KEY
);""")
cursor.execute("""
create table if not exists alternativas(
opcao VARCHAR(80) NOT NULL,
votacao VARCHAR(80),
PRIMARY KEY (opcao, votacao),
FOREIGN KEY (votacao) REFERENCES votacoes(titulo)
);""")
cursor.execute("""
create table if not exists votos(
nome VARCHAR(80),
opcao VARCHAR(80),
votacao VARCHAR(80),
PRIMARY KEY (nome, votacao),
FOREIGN KEY (opcao, votacao) REFERENCES alternativas(opcao, votacao)
)""")
cursor.execute("""
create table if not exists cronogramas(
titulo VARCHAR(80),
orador VARCHAR(80),
descricao VARCHAR(120),
data DATE,
primary key (titulo)
);
""")
print("Conectado ao banco de dados")