Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Support for psycopg2 client #21

@watarukura

Description

@watarukura

I want to use redash without PostgreSQL backend.
redash use psycopg2 for PostgreSQL driver.
I would be very happy if postlite supports psycopg2.

Here is redash log, use postlite instead of postgres.

 [2023-02-25 11:23:55,763] ERROR in app: Exception on /login [GET]
 Traceback (most recent call last):
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
     response = self.full_dispatch_request()
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
     rv = self.handle_user_exception(e)
   File "/usr/local/lib/python2.7/site-packages/flask_restful/__init__.py", line 271, in error_router
     return original_handler(e)
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
     reraise(exc_type, exc_value, tb)
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
     rv = self.dispatch_request()
   File "/usr/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
     return self.view_functions[rule.endpoint](**req.view_args)
   File "/usr/local/lib/python2.7/site-packages/flask_limiter/extension.py", line 442, in __inner
     return obj(*a, **k)
   File "/app/redash/handlers/authentication.py", line 147, in login
     if current_org == None and not settings.MULTI_ORG:
   File "/usr/local/lib/python2.7/site-packages/werkzeug/local.py", line 365, in <lambda>
     __eq__ = lambda x, o: x._get_current_object() == o
   File "/usr/local/lib/python2.7/site-packages/werkzeug/local.py", line 302, in _get_current_object
     return self.__local()
   File "/app/redash/authentication/org_resolving.py", line 18, in _get_current_org
     g.org = Organization.get_by_slug(slug)
   File "/app/redash/models/organizations.py", line 33, in get_by_slug
     return cls.query.filter(cls.slug == slug).first()
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2895, in first
     ret = list(self[0:1])
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2687, in __getitem__
     return list(res)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 2995, in __iter__
     return self._execute_and_instances(context)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3016, in _execute_and_instances
     close_with_result=True)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3025, in _get_bind_args
     **kw
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/query.py", line 3007, in _connection_from_session
     conn = self.session.connection(**kw)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1035, in connection
     execution_options=execution_options)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1040, in _connection_for_bind
     engine, execution_options)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 409, in _connection_for_bind
     conn = bind.contextual_connect()
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2123, in contextual_connect
     self._wrap_pool_connect(self.pool.connect, None),
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2162, in _wrap_pool_connect
     e, dialect, self)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1476, in _handle_dbapi_exception_noconnection
     exc_info
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 265, in raise_from_cause
     reraise(type(exception), exception, tb=exc_tb, cause=cause)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 2158, in _wrap_pool_connect
     return fn()
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 400, in connect
     return _ConnectionFairy._checkout(self)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 788, in _checkout
     fairy = _ConnectionRecord.checkout(pool)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 529, in checkout
     rec = pool._do_get()
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 1193, in _do_get
     self._dec_overflow()
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 66, in __exit__
     compat.reraise(exc_type, exc_value, exc_tb)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 1190, in _do_get
     return self._create_connection()
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 347, in _create_connection
     return _ConnectionRecord(self)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 474, in __init__
     self.__connect(first_connect_check=True)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/pool.py", line 671, in __connect
     connection = pool._invoke_creator(self)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/strategies.py", line 106, in connect
     return dialect.connect(*cargs, **cparams)
   File "/usr/local/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 412, in connect
     return self.dbapi.connect(*cargs, **cparams)
   File "/usr/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 130, in connect
     conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
 OperationalError: (psycopg2.OperationalError) server didn't return client encoding (Background on this error at: http://sqlalche.me/e/e3q8)
 [2023-02-25 11:23:55,772][PID:14][INFO][metrics] method=GET path=/login end

Here is my investigation repo.
https://github.com/watarukura/redash-postlite
Clone and docker compose up and open http://localhost, you can see error log.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions