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

Cursors do not share the connection #248

Open
andribas404 opened this issue Aug 30, 2021 · 0 comments
Open

Cursors do not share the connection #248

andribas404 opened this issue Aug 30, 2021 · 0 comments

Comments

@andribas404
Copy link

First of all, thanks for this project we used it in production and it is doing well!
In conjunction with the second package clickhouse-sqlalchemy we have great ORM.
However, when creating the session we have noticed that many requests connect to the server directly not using the session.
In our case URL for the server is a round-robin algorithm to select replica and we supposed that session will stick to a particular one.

Maybe there is another approach you could recommend to achieve this goal?

Describe the bug
According to PEP-249

Cursors created from the same connection are not isolated

To Reproduce

from clickhouse_driver import connect
dsn = 'clickhouse://localhost'
conn = connect(dsn)
cursor1 = conn.cursor()
cursor1.execute('CREATE TEMPORARY TABLE test_temp (x int)')
cursor1.close()
cursor2 = conn.cursor()
cursor2.execute('select * from test_temp')
cursor2.fetchall()

Throws

ServerException: Code: 60.
DB::Exception: Table default.test_temp doesn't exist.

Expected behavior

Expected behavior that table test_temp should be visible in the second cursor as here

from clickhouse_driver import connect
dsn = 'clickhouse://localhost'
conn = connect(dsn)
cursor1 = conn.cursor()
cursor1.execute('CREATE TEMPORARY TABLE test_temp (x int)')
cursor1.execute('select * from test_temp')
cursor1.fetchall() 

[]

Versions

  • Version of package with the problem. 0.2.1
  • Python version. 3.7
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

1 participant