Advertisement
Guest User

novo

a guest
Aug 31st, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. def run(self):
  2.         try:
  3.             # Connect to an existing database
  4.             self.conexao = psycopg2.connect(database=self.DATABASE_NAME, user=self.DATABASE_USERNAME, password=self.DATABASE_PASSWORD)
  5.  
  6.             # Because of the way sessions interact with notifications (see NOTIFY documentation), you should keep the connection in autocommit mode if you wish to receive or send notifications in a timely manner.
  7.             self.conexao.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
  8.  
  9.             # Open a cursor to execute queries in the database
  10.             # Fetch the results in an associative array
  11.             self.cursor = self.conexao.cursor(cursor_factory=psycopg2.extras.DictCursor)
  12.  
  13.            
  14.  
  15.         except:
  16.             self.logger.critical('Unable to connect to database and execute run')
  17.  
  18.             self.fetchUsers()
  19.             self.checkRanking()
  20.             self.pool.wait_completion()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement