Part of sasync.database View In Hierarchy
Known subclasses: sasync.items.Transactor, sasync.parray.Transactor, sasync.search.Search, sasync.test.test_database.AutoSetupBroker, sasync.test.test_database.MyBroker, sasync.test.test_orm.ObjectBroker
I manage asynchronous access to a database.
Before you use any instance of me, you must specify the parameters for creating an SQLAlchemy database engine. A single argument is used, which specifies a connection to a database via an RFC-1738 url. In addition, the following keyword options can be employed, which are listed below with their default values.
You can set an engine globally, for all instances of me via the
sasync.engine package-level function, or via my engine
class method. Alternatively, you can specify an engine for one particular
instance by supplying the parameters to the constructor.
| Instance Variables | dt | A property-generated reference to a deferred tracker that you can use to
wait for database writes. See misc.DeferredTracker.
|
| q | A property-generated reference to a threaded task queue that is dedicated to my database connection. | |
| connection | The current SQLAlchemy connection object, if any yet exists. Generated
by my connect
method.
|
| Method | __init__ | Constructs an instance of me, optionally specifying parameters for an |
| Class Method | engine | Sets default connection parameters for all instances of me. |
| Method | _getDeferredTracker | Returns an instance of misc.DeferredTracker
that is dedicated to the
|
| Method | _getQueue | Returns a threaded task queue that is dedicated to my database |
| Method | connect | Generates and returns a singleton connection object. |
| Method | _sessionClose | Replacement close method for session objects.
|
| Method | getSession | Get a commitable session object |
| Method | table | Instantiates a new table object, creating it in the transaction thread |
| Method | startup | This method runs before the first transaction to start my synchronous |
| Method | userStartup | If this method is defined and startup
is not overridden in your
|
| Method | first | This method automatically runs as the first transaction after |
| Method | shutdown | Shuts down my database transaction functionality and threaded task |
| Method | s | Polymorphic method for working with select instances within
a cached
|
| Method | queryToList | Executes my current select object with the bind parameters supplied as |
| Method | deferToQueue | Dispatches callable(*args, **kw) as a task via the like-named method |
misc.DeferredTracker
that is dedicated to the bound method's instance of me. Creates the
deferred tracker the first time this method is called for a given instance
of me.
Instantiates a new table object, creating it in the transaction thread as needed.
One or more indexes other than the primary key can be defined via a keyword prefixed with index_ or unique_ and having the index name as the suffix. Use the unique_ prefix if the index is to be a unique one. The value of the keyword is a list or tuple containing the names of all columns in the index.This method runs before the first transaction to start my synchronous task queue. Override it to get whatever pre-transaction stuff you have run.
Alternatively, with legacy support for the old API, your pre-transaction code can reside in auserStartup
method of your subclass.
If this method is defined and startup
is not overridden in your subclass, however, this method will be run as the
first callback in the deferred processing chain, after my synchronous task
queue is safely underway.
The method should return either an immediate result or a deferred to an eventual result.
Deprecated: Instead of defining this method, your subclass should simply overridestartup
with your custom startup stuff.
This method automatically runs as the first transaction after completion
of startup
(or userStartup).
Override it to define table contents or whatever else you want as a
first transaction that immediately follows your pre-transaction stuff.
@transact, but
it doesn't break anything if you do.
select instances within
a cached selection subcontext.
sqlalchemy.select(...).compile(), except that nothing
is returned. Instead, the resulting select object is stored in the
current selection subcontext.
Dispatches callable(*args, **kw) as a task via the like-named method of my synchronous queue, returning a deferred to its eventual result.
Scheduling of the task is impacted by the niceness keyword that can be included in **kw. As with UNIX niceness, the value should be an integer where 0 is normal scheduling, negative numbers are higher priority, and positive numbers are lower priority.| Unknown Field: keyword | niceness | Scheduling niceness, an integer between -20 and 20, with lower numbers
having higher scheduling priority as in UNIX nice and
renice.
|