Skip to content

Instantly share code, notes, and snippets.

@lucas404x
Created June 22, 2019 02:29
Show Gist options
  • Save lucas404x/2069347db1ef8d4f7c665dda09240f7b to your computer and use it in GitHub Desktop.
Save lucas404x/2069347db1ef8d4f7c665dda09240f7b to your computer and use it in GitHub Desktop.
import sqlite3
def create_table():
c.execute('create table IF NOT EXISTS dados(id INTEGER PRIMARY KEY AUTOINCREMENT,\
nome text,\
data_nascimento text,\
email text,\
senha text)')
def read_data():
data = c.execute("SELECT * from dados")
return data.fetchall()
def insert_data(nome, data_nascimento, email, senha):
c.execute('insert into dados VALUES(NULL, ?, ?, ?, ?)', (str(nome), str(data_nascimento), str(email), str(senha)))
connection.commit()
def write_data(file):
with open(file, mode='w') as f:
data = read_data()
for i in data:
f.write("..." + "\n")
for data_ in i:
f.write(str(data_) + "\n")
def update_password(ID, password):
c.execute('UPDATE dados SET senha = ? WHERE id = ?', (password, ID))
connection.commit()
def remove_data(ID):
c.execute('delete from dados where id = '+ ID)
connection.commit()
def search_Id(email, senha):
data = read_data()
for d in data:
if d[3] == email and d[4] == senha:
return str(d[0])
return
connection = sqlite3.Connection("dados_usuarios.db")
c = connection.cursor()
create_table()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment