{"id":20259818,"url":"https://github.com/influxdata/flightsql-dbapi","last_synced_at":"2025-04-22T12:26:35.602Z","repository":{"id":65451492,"uuid":"585288093","full_name":"influxdata/flightsql-dbapi","owner":"influxdata","description":"DB API 2 interface for Flight SQL with SQLAlchemy extras.","archived":false,"fork":false,"pushed_at":"2025-03-27T22:27:30.000Z","size":192,"stargazers_count":37,"open_issues_count":8,"forks_count":5,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-03-29T15:09:49.488Z","etag":null,"topics":["apache-arrow","dbapi2","flight-sql","python","sqlalchemy"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/influxdata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-04T19:45:45.000Z","updated_at":"2025-02-14T05:23:51.000Z","dependencies_parsed_at":"2023-10-03T01:29:39.108Z","dependency_job_id":"2a01878a-4ae5-4367-88a0-4fae36b13dc7","html_url":"https://github.com/influxdata/flightsql-dbapi","commit_stats":{"total_commits":95,"total_committers":5,"mean_commits":19.0,"dds":0.0736842105263158,"last_synced_commit":"dea143e94948fab48c479936f79ba34e9ce6edd8"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influxdata%2Fflightsql-dbapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influxdata%2Fflightsql-dbapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influxdata%2Fflightsql-dbapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/influxdata%2Fflightsql-dbapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/influxdata","download_url":"https://codeload.github.com/influxdata/flightsql-dbapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250239087,"owners_count":21397633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache-arrow","dbapi2","flight-sql","python","sqlalchemy"],"created_at":"2024-11-14T11:16:44.582Z","updated_at":"2025-04-22T12:26:35.553Z","avatar_url":"https://github.com/influxdata.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":":warning: This library is experimental.  Further development may be spotty since\n[influxdb3-python](https://github.com/InfluxCommunity/influxdb3-python) module is the\n[recommended Python API](https://docs.influxdata.com/influxdb/cloud-serverless/reference/client-libraries/v3/python/).\n\nThe APIs provided here may change and functionality may not be maintained.  Use at your own risk.\n\n## Overview\n\nThis library provides a [DB API 2](https://peps.python.org/pep-0249/) interface\nand [SQLAlchemy](https://www.sqlalchemy.org) Dialect for [Flight\nSQL](https://arrow.apache.org/docs/format/FlightSql.html) for example to interact with InfluxDB IOx in our Cloud product.\n\nInitially, this library aims to ease the process of connecting to Flight SQL\nAPIs in [Apache Superset](https://superset.apache.org).\n\nThe primary SQLAlchemy Dialect provided by `flightsql-dbapi` targets the\n[DataFusion](https://arrow.apache.org/datafusion) SQL execution engine. However,\nthere extension points to create custom dialects using Flight SQL as a transport\nlayer and for metadata discovery.\n\n## Installation\n\n```shell\n$ pip install flightsql-dbapi\n```\n\n## Usage\n\n### DB API 2 Interface ([PEP-249](https://peps.python.org/pep-0249))\n\n```python3\nfrom flightsql import connect, FlightSQLClient\n\nclient = FlightSQLClient(host='upstream.server.dev')\nconn = connect(client)\ncursor = conn.cursor()\ncursor.execute('select * from runs limit 10')\nprint(\"columns:\", cursor.description)\nprint(\"rows:\", [r for r in cursor])\n```\n\n### SQLAlchemy\n\n```python3\nimport flightsql.sqlalchemy\nfrom sqlalchemy import func, select\nfrom sqlalchemy.engine import create_engine\nfrom sqlalchemy.schema import MetaData, Table\n\nengine = create_engine(\"datafusion+flightsql://john:appleseeds@upstream.server.dev:443\")\nruns = Table(\"runs\", MetaData(bind=engine), autoload=True)\ncount = select([func.count(\"*\")], from_obj=runs).scalar()\nprint(\"runs count:\", count)\nprint(\"columns:\", [(r.name, r.type) for r in runs.columns])\n\n# Reflection\nmetadata = MetaData(schema=\"iox\")\nmetadata.reflect(bind=engine)\nprint(\"tables:\", [table for table in metadata.sorted_tables])\n```\n\n### Custom Dialects\n\nIf your database of choice can't make use of the Dialects provided by this\nlibrary directly, you can extend `flightsql.sqlalchemy.FlightSQLDialect` as a\nstarting point for your own custom Dialect.\n\n```python3\nfrom flightsql.sqlalchemy import FlightSQLDialect\nfrom sqlalchemy.dialects import registry\n\nclass CustomDialect(FlightSQLDialect):\n    name = \"custom\"\n    paramstyle = 'named'\n\n    # For more information about what's available to override, visit:\n    # https://docs.sqlalchemy.org/en/14/core/internals.html#sqlalchemy.engine.default.DefaultDialect\n\nregistry.register(\"custom.flightsql\", \"path.to.your.module\", \"CustomDialect\")\n```\n\nDB API 2 Connection creation is provided by `FlightSQLDialect`.\n\nThe core reflection APIs of `get_columns`, `get_table_names` and\n`get_schema_names` are implemented in terms of Flight SQL API calls so you\nshouldn't have to override those unless you have very specific needs.\n\n### Directly with `flightsql.FlightSQLClient`\n\n```python3\nfrom flightsql import FlightSQLClient\n\n\nclient = FlightSQLClient(host='upstream.server.dev',\n                         port=443,\n                         token='rosebud-motel-bearer-token')\ninfo = client.execute(\"select * from runs limit 10\")\nreader = client.do_get(info.endpoints[0].ticket)\n\ndata_frame = reader.read_all().to_pandas()\n```\n\n### Authentication\n\nBoth [Basic and Bearer Authentication](https://arrow.apache.org/docs/format/Flight.html#authentication) are supported.\n\nTo authenticate using Basic Authentication, supply a DSN as follows:\n\n```\ndatafusion+flightsql://user:password@host:443\n```\n\nA handshake will be performed with the upstream server to obtain a Bearer token.\nThat token will be used for the remainder of the engine's lifetype.\n\nTo authenticate using Bearer Authentication directly, supply a `token` query parameter\ninstead:\n\n```\ndatafusion+flightsql://host:443?token=TOKEN\n```\n\nThe token will be placed in an appropriate `Authentication: Bearer ...` HTTP header.\n\n### Additional Query Parameters\n\n| Name | Description | Default |\n| ---- | ----------- | ------- |\n| `insecure` | Connect without SSL/TLS (h2c) | `false` |\n| `disable_server_verification` | Disable certificate verification of the upstream server | `false` |\n| `token` | Bearer token to use instead of Basic Auth | empty |\n\nAny query parameters *not* specified in the above table will be sent to the\nupstream server as gRPC metadata.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfluxdata%2Fflightsql-dbapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finfluxdata%2Fflightsql-dbapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finfluxdata%2Fflightsql-dbapi/lists"}