apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
62.53k stars 13.77k forks source link

Include jdbc-sqlalchemy / jaedebeapi db driver for jdbc #12550

Closed squalou closed 2 years ago

squalou commented 3 years ago

Is your feature request related to a problem? Please describe.

I use some DB that are not yet supported by superset or sqlalchemy. BUT jdbc drivers are available.

This project seems to bridge the gap between jdbc and sqlalchemy

more specifically .... jaydebeapi does.

https://pypi.org/project/sqlalchemy-jdbcapi/

Would be a great news to have this supported

Describe the solution you'd like

Support jdbc connectors provided suiting jar is given.

Describe alternatives you've considered

for my specific case right now, see #12544 but I feel like its' even worse.

Additional context

I'm running Superset inside a container in which I installed jaydebeapi ith pip and a jre

This snippet works.

import jaydebeapi
from os import environ
environ['JAVA_HOME']="/usr/lib/jvm/java-8-openjdk-amd64/"
conn = jaydebeapi.connect("software.amazon.timestream.jdbc.TimestreamDriver",
         "jdbc:timestream",
         {'AccessKeyId':"mykey", 'SecretAccessKey':"mysecret", 'Region':"eu-east-1"},
         "/etc/amazon-timestream-jdbc-1.0.0.jar")

curs = conn.cursor()
curs.execute('select * from "timestream-test-db".testtable where time > ago(1d)')
data=curs.fetchall()
curs.close()
conn.close()
for d in data:
    print(d)

I did not manage to use the supposedly working sqlalchemy project I mentioned.

Would be incredibly great to be able to use theses connexions, no idea how

dpgaspar commented 3 years ago

Hi @squalou your example is at the dbapi layer, please test using SQLAlchemy with a driver that supports it's dialect:

From the docs (https://github.com/daneshpatel/sqlalchemy-jdbcapi):

from sqlalchemy import create_engine
engine = create_engine('jdbcapi+pgjdbc://{}:{}@{}/{}'.format(username, password, <ip:host>', <database name>))
rows = engine.connect().execute(
    "select * from some_table LIMIT 10"
)
print([row for row in rows])
squalou commented 3 years ago

I've read a bit more about sqlalchemy etc... and indeed, no miracle can occur : I would need a dedicated dialect to begin with :) (I mean : jdbc driver is not enough)