Advertisement
Guest User

Untitled

a guest
Sep 11th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import psycopg2
  2.  
  3. class bancoPostgre:
  4.  
  5. def __init__ (self):
  6. self.__errCon = None
  7.  
  8. def getConexao(self,usuario):
  9. try:
  10. if usuario in 'postgres':
  11. host = 'localhost'
  12. database = 'TesteDevmedia'
  13. username = 'postgres'
  14. password = 'postgres'
  15. else:
  16. print('funcao_nao_encontrada')
  17.  
  18. con = psycopg2.connect(host=host, database=database,user=username, password=password)
  19.  
  20. except ValueError as e:
  21. self.__errCon = str(e)
  22.  
  23. return(con)
  24.  
  25. def getError(self):
  26. return self.__errCon
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement