A question in regards to integrating a horizonal sharder from the example with flask-sqlalchemy
- Rob Fowler
- 2013-04-16 @ 07:21
I have written a horizontal sharding 'plugin' using the ShardedSession
It all works amazingly well just using sqlalchemy but I am now cleaning up
the application and moving the parts into a blueprint style application.
As part of that process I am trying to use stock standard
modules/interfaces and most of the blueprint examples use flask-sqlalchemy.
Does anyone have a hint on how to use a custom session with
I am doing things pretty much the same as the sqlalchemy sharding example:
create_session = sessionmaker(class_=ShardedSession)
and I have a class that has the functions needed to configure the
create_session as follows:
Allt his works with raw sqlalchemy I can't work out how to hook it into
So far I think I have to create a scoped session:
db_session = scoped_session(sessionmaker(class_=ShardedSession,
My question, can I hook this db_session into the normal flask-sqlalchemy
initializer that looks like this?
db = SQLAlchemy(app)