Ejemplo n.º 1
0
    def get_connection(self):
        """Get a connection to this Database. Connections are retrieved from a
        pool.
        """
        if not self.open:
            raise exc.ResourceClosedError('Database closed.')

        return Connection(self._engine.connect())
Ejemplo n.º 2
0
Archivo: db.py Proyecto: aodic/jw-flask
    def get_connection(self):
        """Get a connection to this Database. Connections are retrieved from a
        pool. The retrieved connection remains open until its result is
        consumed.
        """
        if not self.open:
            raise exc.ResourceClosedError("Database closed.")

        return Connection(self.engine.connect())
Ejemplo n.º 3
0
    def get_connection(self, close_with_result=False):
        """Get a connection to this Database. Connections are retrieved from a
        pool. By default, the retrieved connection remains open. Setting
        close_with_result to True returns the connection to the pool once a
        result is consumed.
        """
        if not self.open:
            raise exc.ResourceClosedError('Database closed.')

        return Connection(self._engine.contextual_connect(close_with_result))
Ejemplo n.º 4
0
    def get_session(self):
        """Get a session to use for running queries.

        :rtype: Session

        """
        if not self.is_open:
            raise exc.ResourceClosedError("Database is not open.")

        return Session(self.connection)
Ejemplo n.º 5
0
 def _revalidate_connection(self):
     if self._Connection__can_reconnect and self._Connection__invalid:
         if self._Connection__transaction is not None:
             raise sqla_exc.InvalidRequestError(
                 "Can't reconnect until invalid "
                 "transaction is rolled back")
         self._Connection__connection = self.engine.raw_connection(
             _connection=self)
         self._Connection__invalid = False
         return self._Connection__connection
     raise sqla_exc.ResourceClosedError("This Connection is closed")
Ejemplo n.º 6
0
 def get_connection(self) -> Connection:
     """Gets a connection to the db. Connections are retrieved from a pool."""
     if not self.open:
         raise exc.ResourceClosedError("db closed")
     return Connection(self._engine.connect())
Ejemplo n.º 7
0
 def get_connection(self):
     """Get a connection from the sqlalchemy engine."""
     if not self._open:
         raise exc.ResourceClosedError('Database closed.')
     return self._connection_class(self._engine.connect())
Ejemplo n.º 8
0
    def get_connection(self):
        if not self.open:
            raise exc.ResourceClosedError("Database Closed")

        return Connection(self._engine.connect())