clickhouse-sqlalchemy
clickhouse-sqlalchemy copied to clipboard
chore(docs): Fix quick start example
The current example leads to the following error with sqlalchemy > 2:
TypeError: MetaData.__init__() got an unexpected keyword argument 'bind'
Maybe fixes this: https://github.com/xzkostyan/clickhouse-sqlalchemy/issues/261
@xzkostyan do you mind adding me as a maintainer or we find a way to get small improvements through?
Let's start with a little PR review.
Why we use pure functions instead clickhouse-dialect wrappers here?
It seems that transferring bind=engine from MetaData to .create() call is only related change in this PR. What other changes are about?
It will not fix #261. For some reasons sqlalchemy_utils are used there.
I see what you mean, thanks for the feedback:
engine = create_engine(uri)
# Base = get_declarative_base(metadata=metadata)
# Create a session.
Session = sessionmaker(bind=engine)
session = Session()
metadata = MetaData()
metadata.reflect(bind=engine)
# Define the base class using the declarative base.
Base = declarative_base(metadata=metadata)
this should reflect the metadata part?
Can you explain the difference between clickhouse dialect wrappers?
In general I was assuming clickhouse 2.0 was breaking the docs
This seems to work for now:
metadata = MetaData()
metadata.reflect(bind=engine)
Base = get_declarative_base(metadata=metadata)