influxdata / flightsql-dbapi

DB API 2 interface for Flight SQL with SQLAlchemy extras.
Apache License 2.0
33 stars 5 forks source link

Can this be used with local installation of influx db #16

Open arunjose696 opened 1 year ago

arunjose696 commented 1 year ago

Can FlightSQLClient be used with local installation of influx-db ,

query_client = FlightSQLClient(
    host = "localhost",
    token = token,
   port=8086,
    metadata={"bucket-name": bucket_name})
query = """SELECT *
        FROM table
        """
info = query_client.execute(query)

I got this error when trying to do this

File "<stdin>", line 1, in <module>
  File "C:\Users\arunj\anaconda3\envs\newenv\lib\site-packages\flightsql\client.py", line 123, in execute
    return self._get_flight_info(flightsql.CommandStatementQuery(query=query), call_options)
  File "C:\Users\arunj\anaconda3\envs\newenv\lib\site-packages\flightsql\util.py", line 8, in g
    return f(self, *args, **kwargs)
  File "C:\Users\arunj\anaconda3\envs\newenv\lib\site-packages\flightsql\client.py", line 293, in _get_flight_info
    return self.client.get_flight_info(flight_descriptor(command), options)

  File "pyarrow\_flight.pyx", line 1506, in pyarrow._flight.FlightClient.get_flight_info
  File "pyarrow\_flight.pyx", line 71, in pyarrow._flight.check_flight_status
pyarrow._flight.FlightUnavailableError: Flight returned unavailable error, with message: failed to connect to all addresses; last error: UNKNOWN: ipv4:127.0.0.1:8086: Ssl handshake failed: SSL_ERROR_SSL: error:0A00010B:SSL routines::wrong version number
nightscape commented 1 year ago

I'm also just trying to run this with a local IOx installation. It looks like the SSL verification can be turned off using the insecure parameter:

from flightsql import connect, FlightSQLClient

client = FlightSQLClient(host='localhost', port=8083, insecure=True)
conn = connect(client)
cursor = conn.cursor()
cursor.execute('select * from runs limit 10')
print("columns:", cursor.description)
print("rows:", [r for r in cursor])

I'm now getting a new error:

cursor.execute('select * from runs limit 10')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/martin/Library/Caches/pypoetry/virtualenvs/superset-Ovos_ljV-py3.11/lib/python3.11/site-packages/flightsql/util.py", line 8, in g
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martin/Library/Caches/pypoetry/virtualenvs/superset-Ovos_ljV-py3.11/lib/python3.11/site-packages/flightsql/dbapi.py", line 54, in execute
    info = self.client.execute(query)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martin/Library/Caches/pypoetry/virtualenvs/superset-Ovos_ljV-py3.11/lib/python3.11/site-packages/flightsql/client.py", line 123, in execute
    return self._get_flight_info(flightsql.CommandStatementQuery(query=query), call_options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martin/Library/Caches/pypoetry/virtualenvs/superset-Ovos_ljV-py3.11/lib/python3.11/site-packages/flightsql/util.py", line 8, in g
    return f(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/martin/Library/Caches/pypoetry/virtualenvs/superset-Ovos_ljV-py3.11/lib/python3.11/site-packages/flightsql/client.py", line 293, in _get_flight_info
    return self.client.get_flight_info(flight_descriptor(command), options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "pyarrow/_flight.pyx", line 1506, in pyarrow._flight.FlightClient.get_flight_info
  File "pyarrow/_flight.pyx", line 81, in pyarrow._flight.check_flight_status
  File "pyarrow/error.pxi", line 121, in pyarrow.lib.check_status
pyarrow.lib.ArrowNotImplementedError: Flight returned unimplemented error, with message: Not yet implemented

That's probably related to IOx not yet implementing a few Flight operations.

arunjose696 commented 1 year ago

@nightscape

I got this error . When using insecure parameter in my windows machine.

pyarrow._flight.FlightUnavailableError: Flight returned unavailable error, with message: failed to connect to all addresses; last error: UNKNOWN: ipv4:127.0.0.1:8086: Trying to connect an http1.x server

nightscape commented 1 year ago

It looks like you're trying to connect to a InfluxDB 1.x or 2.x. I think Flight only works with IOx which would have port 8083 for the gRPC calls.