· 4 years ago · Jun 11, 2021, 04:08 PM
1import sqlite3
2
3banco = sqlite3.connect ("ind.db")
4
5cursor = banco.cursor()
6
7def criar_banco():
8 cursor.execute ("CREATE TABLE IF NOT EXISTS indentidade (id integer PRIMARY KEY AUTOINCREMENT, nome VARCHAR(50), cpf VARCHAR(12))")
9
10def limpar():
11 print('\n'*100)
12
13limpar()
14
15onoff = True
16while onoff == True:
17 v_nome = input("nome: ")
18 if v_nome.isnumeric():
19 limpar()
20 print("Apenas letras no campo NOME")
21 else:
22 onoff = False
23onoff = True
24while onoff == True:
25 v_cpf = input("cpf: ")
26 if not v_cpf.isdigit() or len(v_cpf) != 11:
27 limpar()
28 print("CPF Invalido! verifique se esta tudo correto")
29 else:
30 onoff = False
31print('Informacoes salvas com sucesso!')
32
33def adc_dados():
34 cursor.execute ("INSERT INTO indentidade (nome, cpf) VALUES (?,?)",(v_nome,v_cpf))
35criar_banco()
36adc_dados()
37banco.commit()
38