Advertisement
Guest User

login com banco

a guest
Oct 11th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. import psycopg2
  2.  
  3. conn = psycopg2.connect("dbname='nome_do_banco'user='postgres'host='localhost'password='postgres'");
  4. cur = conn.cursor()
  5.  
  6.   def verifica_campos(self):
  7.         usuario = unicode(self.campo_escrever_usuario.text())
  8.         senha = unicode(self.campo_escrever_senha.text())
  9.  
  10.         cur.execute("SELECT * FROM usuarios where email_usuario = %s and senha_usuario = %s", (usuario,senha,))
  11.         print(cur.fetchone())
  12.  
  13.         if cur.rowcount > 0:
  14.             self.abre_tela_principal()
  15.         else:
  16.             self.mensagem_erro_login(_fromUtf8('Atenção!'), _fromUtf8('Usuário ou Senha incorretos!'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement