Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pg8000 import connect
- from todo_project.utils.singleton import Singleton
- class Database(Singleton):
- def __init__(self, user, password, database):
- """
- Constructor
- :param user: User's login
- :param password: User's password
- :param database: Database name
- """
- if not hasattr(self, 'connection'):
- self.connection = connect(
- user=user,
- password=password,
- database=database
- )
- def close(self):
- """
- Function for destroying and
- cleaning up resources after
- using connection to database
- """
- self.connection.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement