django_sorcery.db.sqlalchemy module¶
SQLAlchemy goodies that provides a nice interface to using sqlalchemy with django.
-
class
django_sorcery.db.sqlalchemy.
SQLAlchemy
(url, **kwargs)[source]¶ Bases:
django_sorcery.db.relations.RelationsMixin
This class itself is a scoped session and provides very thin and useful abstractions and conventions for using sqlalchemy with django.
-
class
BaseComposite
(*args, **kwargs)¶ Bases:
object
Base class for creating composite classes which
CompositeField
will understand.For example:
class MyComposite(object): foo = db.Column(db.Integer()) bar = db.Column(db.Integer()) class MyModel(db.Model): test = db.CompositeField(MyComposite) # both test_foo and test_bar columns will be added to model # their instrumented properties will be _test_foo and _test_bar
-
as_dict
()¶ Serializer composite to a dictionary.
-
-
class
CompositeField
(class_, **kwargs)¶ Bases:
sqlalchemy.orm.descriptor_props.CompositeProperty
Composite field which understands composite objects with builtin columns.
See
BaseComposite
for examples.-
instrument_class
(mapper)¶ Hook called by the Mapper to the property to initiate instrumentation of the class attribute managed by this MapperProperty.
The MapperProperty here will typically call out to the attributes module to set up an InstrumentedAttribute.
This step is the first of two steps to set up an InstrumentedAttribute, and is called early in the mapper setup process.
The second step is typically the init_class_attribute step, called from StrategizedProperty via the post_instrument_class() hook. This step assigns additional state to the InstrumentedAttribute (specifically the “impl”) which has been determined after the MapperProperty has determined what kind of persistence management it needs to do (e.g. scalar, object, collection, etc).
-
-
Table
(name, *args, **kwargs)[source]¶ Returns a sqlalchemy table that is automatically added to metadata.
-
add
(*args, **kwargs)¶
-
add_all
(*args, **kwargs)¶
-
autocommit
¶
-
autoflush
¶
-
begin
(*args, **kwargs)¶
-
begin_nested
(*args, **kwargs)¶
-
bind
¶
-
bind_mapper
(*args, **kwargs)¶
-
bind_table
(*args, **kwargs)¶
-
bulk_insert_mappings
(*args, **kwargs)¶
-
bulk_save_objects
(*args, **kwargs)¶
-
bulk_update_mappings
(*args, **kwargs)¶
-
close
(*args, **kwargs)¶
-
close_all
(*args, **kwargs)¶
-
commit
(*args, **kwargs)¶
-
connection
(*args, **kwargs)¶
-
connection_callable
¶
-
delete
(*args, **kwargs)¶
-
deleted
¶
-
dirty
¶
-
dispatch
¶
-
enable_baked_queries
¶
-
enable_relationship_loading
(*args, **kwargs)¶
-
engine
¶ Current engine.
-
execute
(*args, **kwargs)¶
-
expire
(*args, **kwargs)¶
-
expire_all
(*args, **kwargs)¶
-
expire_on_commit
¶
-
expunge
(*args, **kwargs)¶
-
expunge_all
(*args, **kwargs)¶
-
flush
(*args, **kwargs)¶
-
future
¶
-
get
(*args, **kwargs)¶
-
get_bind
(*args, **kwargs)¶
-
get_nested_transaction
(*args, **kwargs)¶
-
get_transaction
(*args, **kwargs)¶
-
hash_key
¶
-
identity_key
(*args, **kwargs)¶
-
identity_map
¶
-
in_nested_transaction
(*args, **kwargs)¶
-
in_transaction
(*args, **kwargs)¶
-
info
¶
-
inspector
¶ Returns engine inspector.
Useful for querying for db schema info.
-
invalidate
(*args, **kwargs)¶
-
is_active
¶
-
is_modified
(*args, **kwargs)¶
-
merge
(*args, **kwargs)¶
-
metadata_class
¶ alias of
sqlalchemy.sql.schema.MetaData
-
model_class
¶ alias of
django_sorcery.db.models.Base
-
new
¶
-
no_autoflush
¶
-
object_session
(*args, **kwargs)¶
-
prepare
(*args, **kwargs)¶
-
query
(*args, **kwargs)¶
-
query_class
¶ alias of
django_sorcery.db.query.Query
-
refresh
(*args, **kwargs)¶
-
registry
¶ Returns scoped registry instance.
-
registry_class
¶ alias of
sqlalchemy.util._collections.ThreadLocalRegistry
-
rollback
(*args, **kwargs)¶
-
scalar
(*args, **kwargs)¶
-
scalars
(*args, **kwargs)¶
-
session
(**kwargs)[source]¶ Return the current session, creating it if necessary using session_factory for the current scope Any kwargs provided will be passed on to the session_factory.
If there’s already a session in current scope, will raise InvalidRequestError
-
session_class
¶
-
session_factory
¶ Current session factory to create sessions.
-
transaction
¶
-
twophase
¶
-
class