Advertisement
LucasPy

gerador de qrcode em codigo

Jun 29th, 2022
824
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sqlite3
  2. import random
  3. import qrcode
  4. import string
  5. from datetime import *
  6.  
  7. banco = sqlite3.connect ("codigos.db")
  8. cursor = banco.cursor()
  9.  
  10.  
  11.  
  12.  
  13. cursor.execute ("CREATE TABLE IF NOT EXISTS codigosV (codeValido VARCHAR(8), dataHora VARCHAR(17), nomeVendedor VARCHAR(25), emailCliente VARCHAR(50))")
  14.  
  15. cursor.execute ("CREATE TABLE IF NOT EXISTS codigosN (codeNvalido VARCHAR(8))")
  16.  
  17.  
  18. def criarQRcode():
  19.  
  20.  
  21.     vendedor = input("Nome vendedor: ")
  22.     email = input("email cliente: ")
  23.  
  24.     data = datetime.now()
  25.     dataSimples = data.strftime('%d/%m/%Y %H:%M')
  26.     print (dataSimples)
  27.  
  28.  
  29.     QRcode = 1
  30.     code = 8
  31.  
  32.     for x in range(QRcode):
  33.       CodigoFinal = (''.join(random.choice(string.ascii_letters + string.digits) for _ in range(code)))
  34.  
  35.     print (CodigoFinal)
  36.  
  37.  
  38.     cursor.execute ("INSERT INTO codigosV (codeValido, dataHora, nomeVendedor, emailCliente) VALUES (?,?,?,?)",(CodigoFinal,dataSimples,vendedor,email))
  39.  
  40.     cursor.execute("""
  41.    SELECT * FROM codigosV;
  42.    """)
  43.  
  44.     for linha in cursor.fetchall():
  45.         print(linha)
  46.  
  47.  
  48.     img = qrcode.make (CodigoFinal)
  49.     type(img)
  50.     img.save(f"QRcodeFor {email} .png")
  51.  
  52.  
  53. def lerQRcode():
  54.    
  55.     lerCodigo = input("codigo:")
  56.  
  57.     cursor.execute(f""" SELECT * FROM codigosV WHERE codeValido = '{lerCodigo}' """)  
  58.  
  59.     codigodb = cursor.fetchall()
  60.     print (codigodb)
  61.  
  62.  
  63.     if codigodb :
  64.         print("ok")
  65.     else:
  66.         print("fake")
  67.        
  68.        
  69. print("criar um QRcode (1)")
  70. print("Verificar codigo (2)")
  71.  
  72. tabela = cursor.fetchall()
  73. print(tabela[0][0])
  74.  
  75.  
  76. opcao = (int(input(">> ")))
  77.  
  78.  
  79.  
  80.  
  81. if opcao == 1 :
  82.     criarQRcode()
  83. if opcao == 2 :
  84.     lerQRcode()
  85.  
  86.  
  87. banco.commit()
  88.  
Advertisement
RAW Paste Data Copied
Advertisement