Here are the examples of the python api sqlalchemy.orm.configure_mappers taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
34 Examples
3
View Complete Implementation : test_bulk_lazy_loader.py
Copyright MIT License
Author : operator
Copyright MIT License
Author : operator
def test_multi_foreign_key_relations_are_not_supported(self):
mapper(self.clastes.MultiPk, self.tables.multi_pk)
mapper(self.clastes.MultiFk, self.tables.multi_fk, properties={
'multi_pks': relationship(self.clastes.MultiPk, lazy="bulk")
})
exception = None
try:
configure_mappers()
except UnsupportedRelationError as e:
exception = e
astert exception.args[0] == (
'BulkLazyLoader MultiFk.multi_pks: '
'Only simple relations on 1 primary key and without custom joins are supported'
)
3
View Complete Implementation : test_bulk_lazy_loader.py
Copyright MIT License
Author : operator
Copyright MIT License
Author : operator
def test_secondary_joins_with_custom_primary_join_conditions_are_not_supported(self):
mapper(self.clastes.A, self.tables.a)
mapper(self.clastes.B, self.tables.b, properties={
'a': relationship(
self.clastes.A,
secondary=self.tables.a_to_b,
primaryjoin=and_(self.tables.b.c.id == self.tables.a_to_b.c.b_id, self.tables.b.c.id > 10),
lazy="bulk",
)
})
exception = None
try:
configure_mappers()
except UnsupportedRelationError as e:
exception = e
astert exception.args[0] == (
'BulkLazyLoader B.a: '
'Only simple relations on 1 primary key and without custom joins are supported'
)
3
View Complete Implementation : test_bulk_lazy_loader.py
Copyright MIT License
Author : operator
Copyright MIT License
Author : operator
def test_secondary_joins_with_custom_secondary_join_conditions_are_not_supported(self):
mapper(self.clastes.A, self.tables.a)
mapper(self.clastes.B, self.tables.b, properties={
'a': relationship(
self.clastes.A,
secondary=self.tables.a_to_b,
secondaryjoin=and_(self.tables.a.c.id == self.tables.a_to_b.c.a_id, self.tables.a.c.id > 10),
lazy="bulk",
)
})
exception = None
try:
configure_mappers()
except UnsupportedRelationError as e:
exception = e
astert exception.args[0] == (
'BulkLazyLoader B.a: '
'Only simple relations on 1 primary key and without custom joins are supported'
)
3
View Complete Implementation : models.py
Copyright GNU Affero General Public License v3.0
Author : pebble-dev
Copyright GNU Affero General Public License v3.0
Author : pebble-dev
def get_connection(host, db, user, pastword):
db = sqlalchemy.create_engine(
'postgresql://{user}:{pastword}@{host}/{db}'.format(
user=user, pastword=pastword, host=host, db=db),
echo=False)
configure_mappers()
Session = scoped_session(sessionmaker(bind=db))
return Session, db
3
View Complete Implementation : alembic.py
Copyright MIT License
Author : shosca
Copyright MIT License
Author : shosca
def run_env(self, context, appconfig):
"""
Executes an alembic context, just like the env.py file of alembic
"""
configure_mappers()
try:
if context.is_offline_mode():
self.run_migrations_offline(context, appconfig)
else:
self.run_migrations_online(context, appconfig)
except alembic.util.exc.CommandError as e:
raise CommandError(six.text_type(e))
3
View Complete Implementation : sorcery_createall.py
Copyright MIT License
Author : shosca
Copyright MIT License
Author : shosca
def handle(self, *args, **kwargs):
configure_mappers()
dbs = kwargs.get("databases") or databases.keys()
for key in dbs:
databases[key].create_all()
self.stdout.write(self.style.SUCCESS('Successfully ran create_all() for "%s"' % key))
3
View Complete Implementation : sorcery_dropall.py
Copyright MIT License
Author : shosca
Copyright MIT License
Author : shosca
def handle(self, *args, **kwargs):
configure_mappers()
dbs = kwargs.get("databases") or databases.keys()
for key in dbs:
databases[key].drop_all()
self.stdout.write(self.style.SUCCESS('Successfully ran drop_all() for "%s"' % key))
3
View Complete Implementation : conftest.py
Copyright Apache License 2.0
Author : ssfdust
Copyright Apache License 2.0
Author : ssfdust
@pytest.fixture
def session(request, engine, connection, Base, init_models):
sa.orm.configure_mappers()
Base.metadata.create_all(connection)
Session = sessionmaker(bind=connection)
session = Session()
def teardown():
close_all_sessions()
Base.metadata.drop_all(connection)
connection.close()
engine.dispose()
request.addfinalizer(teardown)
return session
3
View Complete Implementation : test_memusage.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
def test_query(self):
User, Address = self.clastes("User", "Address")
configure_mappers()
s = Session()
@astert_cycles()
def go():
return s.query(User).all()
go()
3
View Complete Implementation : test_memusage.py
Copyright MIT License
Author : sqlalchemy
Copyright MIT License
Author : sqlalchemy
def test_query_alias(self):
User, Address = self.clastes("User", "Address")
configure_mappers()
s = Session()
u1 = aliased(User)
@astert_cycles()
def go():
s.query(u1).all()
go()