-
Notifications
You must be signed in to change notification settings - Fork 0
/
bancodedados.py
33 lines (25 loc) · 1.27 KB
/
bancodedados.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
from psycopg2 import *
def consultarDB():
db = connect('postgres://cobbspuz:[email protected]/cobbspuz')
with db.cursor() as cursor:
cursor.execute("SELECT * FROM usuarios;")
return cursor.fetchall()
db.close()
def cadastrarDB(nome, email, senha):
db = connect('postgres://cobbspuz:[email protected]/cobbspuz')
with db.cursor() as cursor:
cursor.execute("INSERT INTO usuarios (nome, email, senha) VALUES (%s, %s, %s) ;", (nome, email, senha,))
db.commit()
db.close()
def consultarSimu():
db = connect('postgres://cobbspuz:[email protected]/cobbspuz')
with db.cursor() as cursor:
cursor.execute("SELECT * FROM simulacoes;")
return cursor.fetchall()
db.close()
def cadastrarSimu(userres, nomesimu, idh, iev, ie, ir):
db = connect('postgres://cobbspuz:[email protected]/cobbspuz')
with db.cursor() as cursor:
cursor.execute("INSERT INTO simulacoes (userres, nomesimu, ressimu, iev, ie, ir) VALUES (%s, %s, %s, %s, %s, %s) ;", (userres, nomesimu, idh, iev, ie, ir))
db.commit()
db.close()