API Reference¶
Many of these classes are missing methods from the SQLALchemy API. We encourage you to file bugs in those cases.
-
alchimia.wrap_engine(reactor, engine, create_worker=...)¶ This returns a
alchimia.engine.TwistedEngine.The main entry-point to alchimia. To be used like so:
from sqlalchemy import create_engine from alchimia import wrap_engine from twisted.internet import reactor underlying_engine = create_engine("sqlite://") twisted_engine = wrap_engine(reactor, engine)
reactor- the Twisted reactor to use with the createdTwistedEngine.engine- the underlyingsqlalchemy.engine.Enginecreate_worker- The object that will coordinate concurrent blockingwork behind the scenes. The default implementation, if nothing is passed, is one which will use a threadpool where each Connection is tied to an individual thread.
More precisely, this is a callable that is expected to return an object with 2 methods,
do(work)(expected to call the 0-argumentworkcallable in a thread), andquit(), expected to stop any future work from occurring. It may be useful to stub out the default threaded implementation for testing purposes.
-
class
alchimia.engine.TwistedEngine¶ Mostly like
sqlalchemy.engine.Engineexcept some of the methods returnDeferreds.-
__init__(pool, dialect, url, reactor=..., create_worker=...)¶ This constructor is invoked if
TwistedEngineis created viacreate_engine(..., reactor=reactor, strategy=TWISTED_STRATEGY)rather than called directly. New applications should preferalchimia.wrap_engine(). However,create_enginerelays its keyword arguments, so thereactorandcreate_workerarguments have the same meaning as they do inalchimia.wrap_engine().
-
classmethod
from_sqlalchemy_engine(reactor, engine, create_worker=...)¶ This is the implementation of
alchimia.wrap_engine.
-
connect()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with aTwistedConnection.
-
execute(*args, **kwargs)¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with aTwistedResultProxy.
-
has_table(table_name, schema=None)¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with the result.
-
table_names(schema=None, connection=None)¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with the result.
-
-
class
alchimia.engine.TwistedConnection¶ Mostly like
sqlalchemy.engine.Connectionexcept some of the methods returnDeferreds.-
execute(*args, **kwargs)¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with aTwistedResultProxy.
-
close()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires when the connection has been closed.
-
closed¶ Like the SQLAlchemy attribute of the same name.
-
begin()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with aTwistedTransaction.
-
begin_nested()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with aTwistedTransaction.
-
in_transaction()¶ Like the SQLAlchemy method of the same name.
-
-
class
alchimia.engine.TwistedTransaction¶ Mostly like
sqlalchemy.engine.Transactionexcept some of the methods returnDeferreds.-
commit()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires when the transaction has been committed.
-
rollback()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires when the transaction has been rolled back.
-
closed()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires when the transaction has been closed.
-
-
class
alchimia.engine.TwistedResultProxy¶ Mostly like
sqlalchemy.engine.ResultProxyexcept some of the methods returnDeferreds.-
fetchone()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with a row.
-
fetchall()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with a list of rows.
-
scalar()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with the scalar value.
-
first()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with the scalar value.
-
keys()¶ Like the SQLAlchemy method of the same name, except returns a
Deferredwhich fires with the scalar value.
-
close()¶ Like the SQLAlchemy method of the same name, it releases the resources used and releases the underlying DB connection.
-
returns_rows¶ Like the SQLAlchemy attribute of the same name.
-
rowcount¶ Like the SQLAlchemy attribute of the same name.
-
inserted_primary_key¶ Like the SQLAlchemy attribute of the same name.
-