-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanco.py
28 lines (23 loc) · 817 Bytes
/
banco.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
# coding: utf8
import sqlite3
class Banco(object):
def __init__(self):
self.conexao =sqlite3.connect('banco.db')
self.conector = self.conexao.cursor()
def criadorDeTabelas(self):
self.conector.execute("CREATE TABLE IF NOT EXISTS jogo(id INTEGER PRIMARY KEY ASC,pontos INTEGER)")
def inserir(self,pontos):
if(self.busca()==[]):
self.conector.execute("insert into jogo(pontos) values (?)",[int(pontos)])
self.conexao.commit()
elif(int(self.busca()[0][1])<int(pontos)):
self.conector.execute("insert into jogo(pontos) values (?)",[int(pontos)])
self.conexao.commit()
else:
return list([1,0])
def busca(self):
self.conector.execute('SELECT * FROM jogo ORDER BY pontos DESC')
return self.conector.fetchall()
def fechaConexao(self):
self.conector.close()
self.conexao.close()