{
  "schema_version": 2,
  "id": "integrate/redis-arrow-flight/connect",
  "title": "Connect and query",
  "url": "https://redis.io/docs/latest/integrate/redis-arrow-flight/connect/",
  "summary": "Query Redis through the Arrow Flight server from Python and JDBC tools, and store named Arrow datasets.",
  "tags": [
    "docs",
    "integrate",
    "oss",
    "rs",
    "rc"
  ],
  "last_updated": "2026-11-17T10:18:45Z",
  "page_type": "content",
  "content_hash": "efce61d133739ddab7f09a18078d8e83fdb878bd7cdcea103d9d28e282fdd0d4",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "This page shows how to connect to the Redis Arrow Flight server and use its two\ninterfaces: SQL tables through Flight SQL, and named Arrow datasets through\nArrow Flight. The examples assume the server is\n[running](https://redis.io/docs/latest/integrate/redis-arrow-flight/install) at\n`localhost:8815`."
    },
    {
      "id": "query-sql-tables-from-python",
      "title": "Query SQL tables from Python",
      "role": "content",
      "text": "Flight SQL clients use the SQL dialect of the\n[Redis ADBC driver](https://redis.io/docs/latest/integrate/redis-adbc-driver), which is\nclose to PostgreSQL.\n\n1. Install the Flight SQL driver for Python and PyArrow:\n\n    [code example]\n\n1. Create a file named `flight_sql.py`:\n\n    [code example]\n\n1. Run it:\n\n    [code example]\n\n    [code example]\n\nThe `autocommit=True` argument matches how the server runs statements. Without\nit, the driver prints a warning that it can't disable autocommit. Parameters\ncan be written as `?` or `$1`."
    },
    {
      "id": "query-sql-tables-from-jdbc-tools",
      "title": "Query SQL tables from JDBC tools",
      "role": "content",
      "text": "JDBC tools connect with the\n[Arrow Flight SQL JDBC driver](https://arrow.apache.org/java/current/flight_sql_jdbc_driver.html),\n`org.apache.arrow:flight-sql-jdbc-driver`. Use this URL, which turns encryption\noff because the published server doesn't support TLS:\n\n[code example]\n\nRecent Java versions need extra JVM options, or the driver fails before it\nconnects with an `ExceptionInInitializerError`:\n\n| Java version | JVM options |\n| :-- | :-- |\n| 17 to 22 | `--add-opens=java.base/java.nio=ALL-UNNAMED` |\n| 23 and later | `--add-opens=java.base/java.nio=ALL-UNNAMED --sun-misc-unsafe-memory-access=allow` |\n\nJava 17 to 22 refuse to start with the second option, so add it only on\nJava 23 or later. In DBeaver, add the options to `dbeaver.ini` after the\nexisting `-vmargs` line. For DBeaver driver setup, see the project's\n[DBeaver guide](https://redis.github.io/redis-apache-arrow-flight/docs/dbeaver/).\n\nTwo limits of the JDBC driver affect queries. A statement that has no result\nschema runs as an update and returns no rows, which happens with a script of\nseveral statements that changes something, and with `SELECT ?`. Run such a\nquery as its own statement. An untyped parameter accepts only `null`."
    },
    {
      "id": "store-and-read-arrow-datasets",
      "title": "Store and read Arrow datasets",
      "role": "content",
      "text": "Datasets are named Arrow tables that you upload and download without\nconverting them to SQL rows. Each dataset has a path, such as `features/v1`.\n\n1. Create a file named `datasets.py`:\n\n    [code example]\n\n1. Run it:\n\n    [code example]\n\n    [code example]\n\nThe `generation`, `bytes`, and `updated` values in the first line can differ\non your system. The server keeps a generation count for each dataset path,\nand it can carry over from earlier uploads to the same path.\n\nA dataset has one endpoint unless you start the server with\n`-dataset-endpoint-batches`, which splits it into one endpoint per that many\nbatches so that clients can read in parallel. For cancellation, sessions, and\nthe combined dataset and SQL workflow, see the project's\n[data access reference](https://redis.github.io/redis-apache-arrow-flight/docs/data-access/)."
    },
    {
      "id": "next-steps",
      "title": "Next steps",
      "role": "content",
      "text": "- Read the [client guide](https://redis.github.io/redis-apache-arrow-flight/docs/client-guide/)\n  for more examples.\n- Read the [Flight SQL reference](https://redis.github.io/redis-apache-arrow-flight/docs/sql-reference/)\n  for supported statements, streaming, and limits."
    }
  ],
  "examples": [
    {
      "id": "query-sql-tables-from-python-ex0",
      "language": "bash",
      "code": "python -m pip install adbc-driver-flightsql pyarrow",
      "section_id": "query-sql-tables-from-python"
    },
    {
      "id": "query-sql-tables-from-python-ex1",
      "language": "python",
      "code": "import adbc_driver_flightsql.dbapi as flight_sql\n    import pyarrow as pa\n\n    with flight_sql.connect(\"grpc://localhost:8815\", autocommit=True) as conn:\n        with conn.cursor() as cur:\n            cur.adbc_ingest(\n                \"orders\",\n                pa.table({\"id\": [1, 2, 3], \"country\": [\"JPN\", \"USA\", \"JPN\"]}),\n                mode=\"replace\",\n            )\n            cur.execute(\n                \"SELECT country, COUNT(*) AS n FROM orders \"\n                \"WHERE id >= ? GROUP BY country ORDER BY country\",\n                parameters=(2,),\n            )\n            print(cur.fetch_arrow_table())",
      "section_id": "query-sql-tables-from-python"
    },
    {
      "id": "query-sql-tables-from-python-ex2",
      "language": "bash",
      "code": "python flight_sql.py",
      "section_id": "query-sql-tables-from-python"
    },
    {
      "id": "query-sql-tables-from-python-ex3",
      "language": "text",
      "code": "pyarrow.Table\n    country: string\n    n: int64\n    ----\n    country: [[\"JPN\",\"USA\"]]\n    n: [[1,1]]",
      "section_id": "query-sql-tables-from-python"
    },
    {
      "id": "query-sql-tables-from-jdbc-tools-ex0",
      "language": "text",
      "code": "jdbc:arrow-flight-sql://localhost:8815/?useEncryption=false",
      "section_id": "query-sql-tables-from-jdbc-tools"
    },
    {
      "id": "store-and-read-arrow-datasets-ex0",
      "language": "python",
      "code": "import json\n\n    import pyarrow as pa\n    import pyarrow.flight as flight\n\n    client = flight.connect(\"grpc://localhost:8815\")\n    table = pa.table({\"id\": [1, 2], \"embedding\": [[0.1, 0.2], [0.3, 0.4]]})\n    desc = flight.FlightDescriptor.for_path(\"features\", \"v1\")\n\n    # Upload the dataset.\n    writer, results = client.do_put(desc, table.schema)\n    writer.write_table(table)\n    writer.done_writing()\n    print(json.loads(results.read().to_pybytes()))\n    writer.close()\n\n    # Download all of it. Read every endpoint of the FlightInfo.\n    info = client.get_flight_info(desc)\n    print(pa.concat_tables([client.do_get(ep.ticket).read_all() for ep in info.endpoints]))\n\n    # Download only the embedding column of the first 10 batches.\n    ticket = flight.Ticket(\n        json.dumps({\"dataset\": \"features/v1\", \"columns\": [\"embedding\"], \"batches\": [0, 10]}).encode()\n    )\n    print(client.do_get(ticket).read_all())\n\n    # List and drop datasets.\n    print([f.descriptor.path for f in client.list_flights(b\"features/\")])\n    list(client.do_action(flight.Action(\"drop_dataset\", b\"features/v1\")))\n    print([f.descriptor.path for f in client.list_flights(b\"features/\")])",
      "section_id": "store-and-read-arrow-datasets"
    },
    {
      "id": "store-and-read-arrow-datasets-ex1",
      "language": "bash",
      "code": "python datasets.py",
      "section_id": "store-and-read-arrow-datasets"
    },
    {
      "id": "store-and-read-arrow-datasets-ex2",
      "language": "text",
      "code": "{'dataset': 'features/v1', 'generation': 1, 'rows': 2, 'batches': 1, 'bytes': 728, 'updated': '2026-11-11T09:41:37.087467801Z'}\n    pyarrow.Table\n    id: int64\n    embedding: list<item: double>\n      child 0, item: double\n    ----\n    id: [[1,2]]\n    embedding: [[[0.1,0.2],[0.3,0.4]]]\n    pyarrow.Table\n    embedding: list<item: double>\n      child 0, item: double\n    ----\n    embedding: [[[0.1,0.2],[0.3,0.4]]]\n    [[b'features', b'v1']]\n    []",
      "section_id": "store-and-read-arrow-datasets"
    }
  ]
}
