fixture.loadable.sqlobject_loadable
Components for loading and unloading data using SQLObject.
See Using LoadableFixture for examples.
-
class fixture.loadable.sqlobject_loadable.SQLObjectFixture(connection=None, use_transaction=True, close_conn=False, **kw)
Bases: fixture.loadable.loadable.DBLoadableFixture
A fixture that knows how to load DataSet objects via SQLObject classes.
>>> from fixture import SQLObjectFixture
Keyword Arguments:
- style
- A Style object to translate names with
- env
- A dict or module that contains SQLObject classes. The Style object will
look here when translating DataSet names into SQLObject class names.
See EnvLoadableFixture.attach_storage_medium for details on
how env works.
- dsn
- A dsn to create a connection with.
- dataclass
- SuperSet class to represent loaded data with
- medium
- A custom StorageMediumAdapter to instantiate when storing a DataSet.
- use_transaction
- If this is true (default), data will be loaded or torn down inside a
transaction. You may have to set this to false to avoid deadlocks.
However, setting it to false may leave partially loaded data behind
if you create an error with your DataSet.
- close_conn
- True if the connection can be closed, helpful for releasing connections.
If you are passing in a connection object this will be False by default.
-
create_transaction()
- Return a new transaction for connection
-
commit()
- Commit transaction
-
then_finally(unloading=False)
- Unconditionally close the transaction (if configured to do so) after loading data
-
rollback()
- Rollback the transaction
-
class fixture.loadable.sqlobject_loadable.SQLObjectMedium(medium, dataset)
Bases: fixture.loadable.loadable.StorageMediumAdapter
Adapter for storing data using SQLObject classes
-
clear(obj)
- Delete this object from the DB
-
save(row, column_vals)
- Save this row to the DB
-
visit_loader(loader)
- Visit the loader and store a reference to the transaction connection