API Details — SQLSoup 0.9.0 documentation

### Navigation

- index
- modules |
- previous |
- SQLSoup 0.9.0 documentation »

# API Details

This section includes generated documentation for the `SQLSoup` object.

class `sqlsoup.` `SQLSoup`(engine_or_metadata, base=<type 'object'>, session=None)

  Represent an ORM-wrapped database resource.

  `bind`

    The `sqlalchemy.engine.base.Engine` associated with this `SQLSoup`.

  `commit`()

    Commit the current transaction.

    See `sqlalchemy.orm.session.Session.commit()`.

  `connection`()

    Return the current `sqlalchemy.engine.base.Connection` in use by the current transaction.

  `delete`(instance)

    Mark an instance as deleted.

  `engine`

    The `sqlalchemy.engine.base.Engine` associated with this `SQLSoup`.

  `entity`(attr, schema=None)

    Return the named entity from this `SQLSoup`, or create if not present.

    For more generalized mapping, see `map_to()`.

  `execute`(stmt, **params)

    Execute a SQL statement.

    The statement may be a string SQL string, an `sqlalchemy.sql.expression.select()` construct, or a `sqlalchemy.sql.expression.text()` construct.

  `expunge`(instance)

    Remove an instance from the `Session`.

    See `sqlalchemy.orm.session.Session.expunge()`.

  `expunge_all`()

    Clear all objects from the current `Session`.

    See `Session.expunge_all()`.

  `flush`()

    Flush pending changes to the database.

    See `sqlalchemy.orm.session.Session.flush()`.

  `join`(left, right, onclause=None, isouter=False, base=None, **mapper_args)

    Create an `expression.join()` and map to it.

    The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6).

    Parameters: | left – a mapped class or table object. right – a mapped class or table object. onclause – optional “ON” clause construct.. isouter – if True, the join will be an OUTER join. base – a Python class which will be used as the base for the mapped class. If `None`, the “base” argument specified by this `SQLSoup` instance’s constructor will be used, which defaults to `object`. mapper_args – Dictionary of arguments which will be passed directly to `orm.mapper()`.

  `map`(selectable, base=None, **mapper_args)

    Map a selectable directly.

    The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6).

    Parameters: | selectable – an `expression.select()` construct. base – a Python class which will be used as the base for the mapped class. If `None`, the “base” argument specified by this `SQLSoup` instance’s constructor will be used, which defaults to `object`. mapper_args – Dictionary of arguments which will be passed directly to `orm.mapper()`.

  `map_to`(attrname, tablename=None, selectable=None, schema=None, base=None, mapper_args=immutabledict({}))

    Configure a mapping to the given attrname.

    This is the “master” method that can be used to create any configuration.

    Parameters: | attrname – String attribute name which will be established as an attribute on this :class:.`.SQLSoup` instance. base – a Python class which will be used as the base for the mapped class. If `None`, the “base” argument specified by this `SQLSoup` instance’s constructor will be used, which defaults to `object`. mapper_args – Dictionary of arguments which will be passed directly to `orm.mapper()`. tablename – String name of a `Table` to be reflected. If a `Table` is already available, use the `selectable` argument. This argument is mutually exclusive versus the `selectable` argument. selectable – a `Table`, `Join`, or `Select` object which will be mapped. This argument is mutually exclusive versus the `tablename` argument. schema – String schema name to use if the `tablename` argument is present.

  `rollback`()

    Rollback the current transction.

    See `sqlalchemy.orm.session.Session.rollback()`.

  `with_labels`(selectable, base=None, **mapper_args)

    Map a selectable directly, wrapping the selectable in a subquery with labels.

    The class and its mapping are not cached and will be discarded once dereferenced (as of 0.6.6).

    Parameters: | selectable – an `expression.select()` construct. base – a Python class which will be used as the base for the mapped class. If `None`, the “base” argument specified by this `SQLSoup` instance’s constructor will be used, which defaults to `object`. mapper_args – Dictionary of arguments which will be passed directly to `orm.mapper()`.

class `sqlsoup.` `SelectableClassType`

  Represent a SQLSoup mapping to a `sqlalchemy.sql.expression.Selectable` construct, such as a table or SELECT statement.

class `sqlsoup.` `TableClassType`

  Represent a SQLSoup mapping to a `sqlalchemy.schema.Table` construct.

  This object is produced automatically when a table-name attribute is accessed from a `SQLSoup` instance.

  `relate`(propname, *args, **kwargs)

    Produce a relationship between this mapped table and another one.

    This makes usage of SQLAlchemy’s `sqlalchemy.orm.relationship()` construct.

`sqlsoup.` `Session` = <sqlalchemy.orm.scoping.ScopedSession object at 0x101d32fd0>

  SQLSoup’s default session registry.

  This is an instance of `sqlalchemy.orm.scoping.ScopedSession`, and provides a new `sqlalchemy.orm.session.Session` object for each application thread which refers to it.

### Navigation

- index
- modules |
- previous |
- SQLSoup 0.9.0 documentation »