Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flask integration #11

Open
fgbs opened this issue Feb 9, 2018 · 2 comments
Open

flask integration #11

fgbs opened this issue Feb 9, 2018 · 2 comments

Comments

@fgbs
Copy link

fgbs commented Feb 9, 2018

Can you provide an example of how integrate with flask-sqlalchemy?

Best regards.

@xzkostyan
Copy link
Owner

Hi!

Currently there is no integration with flask-sqlalchemy. You can create engine, metadata and pure SQLAlchemy session in following way: https://github.com/xzkostyan/clickhouse-sqlalchemy#sqlalchemy-declarative-support

What kind of integration do you need? Flask thread-local session, config variables, etc? Just want to know.

Two main problems are in custom Table class and get_declarative_base function that uses the same table class. There are some another customizations too.

It's possible to make flask-wrapper for this package, but direct integration with flask-sqlalchemy is hard and maybe monkeypatching way.

@zenglanmu
Copy link

from flask_sqlalchemy import SQLAlchemy
from clickhouse_sqlalchemy.orm.query import Query as ChBaseQuery
ch_db = SQLAlchemy(query_class=ChBaseQuery)

found the SQLAlchemy support to pass custom query_class, so above codes just work for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants