Beispiel #1
0
 def options(self) -> List[Option]:
     with get_connection(
     ) as connection:  #better option to the above: use context manager that was created in connection_pool.py
         options = database.get_poll_options(connection, self.id)
         return [
             Option(option[1], option[2], option[0]) for option in options
         ]
Beispiel #2
0
 def options(self) -> List[Option]:
     with get_connection() as connection:
         options = database.get_poll_options(connection, self.id)
         return [
             Option(option[1], option[2], option[0]) for option in options
         ]
Beispiel #3
0
 def options(self) -> List[Option]:
     connection = create_connection()
     options = database.get_poll_options(connection, self.id)
     connection.close()
     return [Option(option[1], option[2], option[0]) for option in options]
 def options(self) -> List[Option]:
     connection = pool.getconn()
     options = database.get_poll_options(connection, self.id)
     pool.putconn(connection)
     return [Option(option[1], option[2], option[0]) for option in options]