Advertisement
Guest User

Untitled

a guest
Jan 13th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. from pg8000 import connect
  2.  
  3. from todo_project.utils.singleton import Singleton
  4.  
  5.  
  6. class Database(Singleton):
  7. def __init__(self, user, password, database):
  8. """
  9. Constructor
  10.  
  11. :param user: User's login
  12. :param password: User's password
  13. :param database: Database name
  14. """
  15.  
  16. if not hasattr(self, 'connection'):
  17. self.connection = connect(
  18. user=user,
  19. password=password,
  20. database=database
  21. )
  22.  
  23. def close(self):
  24. """
  25. Function for destroying and
  26. cleaning up resources after
  27. using connection to database
  28. """
  29.  
  30. self.connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement