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

Connect to Sybase #7440

Open
CrashLaker opened this issue May 3, 2019 · 3 comments

Comments

Projects
None yet
1 participant
@CrashLaker
Copy link

commented May 3, 2019

Hi all,

I'm trying to connect superset to a sybase database.

I could already connect to it using the following code:

quoted = urllib.parse.quote_plus({FreeTDS};Server=Database;UIDPWD...)
sqlalchemy.create_engine('mssql+pyodbc:///?odbc_connect={}'.format(quoted))

Now when I try to insert this to Superset's "SQL ALCHEMY URI" I get the following error:

ERROR: {"error": "Connection failed!\n\nThe error message returned was:\n(pyodbc.Error) ('IM004', \"[IM004] [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed (0) (SQLDriverConnect)\")\n(Background on this error at: http://sqlalche.me/e/dbapi)"}

[IM004] [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed (0) (SQLDriverConnect)")

I went through some google related issues but It didn't help me.

I also tried installing pip3 install python-sybase with no luck. It returned:

$ pip3 install python-sybase
Collecting python-sybase
  Could not find a version that satisfies the requirement python-sybase (from versions: )
No matching distribution found for python-sybase
You are using pip version 19.0.3, however version 19.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
```
@issue-label-bot

This comment has been minimized.

Copy link

commented May 3, 2019

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

@CrashLaker

This comment has been minimized.

Copy link
Author

commented May 3, 2019

This helped me: https://groups.google.com/forum/#!topic/sqlalchemy/H8ppyC4-3Cg

Now I got this error using mssql+pyodbc://user:pass@host:1433/dbname?driver=FreeTDS.

[FreeTDS][SQL Server]Erro do SQL Anywhere -265: Procedimento 'schema_name' n\u00e3o encontrado\\x00 (504) (SQLExecDirectW)\")\n[SQL: SELECT schema_name()]

I don't know why is it printing in another language but translating it would be:
Procedure 'schema_name' not found...

Got it to work with pyodbc also..

driver = "FreeTDS"
conn = pyodbc.connect(driver=driver, server=serv, database=db,port = prt,
                                   uid=usr, pwd=passwd)
print(conn)
cursor = conn.cursor()
@CrashLaker

This comment has been minimized.

Copy link
Author

commented May 3, 2019

Got it to work..

Now I'm facing the following error:
('42000', "[42000] [FreeTDS][SQL Server]Erro do SQL Anywhere -131: Erro de sintaxe próximo de 'LIMIT' na linha 32\x00 (102) (SQLExecDirectW)")

I know that sybase won't accept limit in the query but I think that is due to superset's automatically inserting the limit value from here:
image

And also because it works in plain python..

how can I by pass it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.