{"record":{"id":"41f3b153bc258e2c","repo":"pola-rs/polars","slug":"only-a-single-sql-query-string-is-accepted-for-adb","errorCode":null,"errorMessage":"only a single SQL query string is accepted for adbc, got a {qualified_type_name(query)!r} type","messagePattern":"only a single SQL query string is accepted for adbc, got a (.+?) type","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/database/functions.py","lineNumber":521,"sourceCode":"            raise ValueError(msg)\n        if pre_execution_query:\n            issue_unstable_warning(\n                \"the 'pre-execution-query' parameter is considered unstable.\"\n            )\n        return _read_sql_connectorx(\n            query,\n            connection_uri=uri,\n            partition_on=partition_on,\n            partition_range=partition_range,\n            partition_num=partition_num,\n            protocol=protocol,\n            schema_overrides=schema_overrides,\n            pre_execution_query=pre_execution_query,\n        )\n    elif engine == \"adbc\":\n        if not isinstance(query, str):\n            msg = f\"only a single SQL query string is accepted for adbc, got a {qualified_type_name(query)!r} type\"\n            raise ValueError(msg)\n        if pre_execution_query:\n            msg = \"the 'adbc' engine does not support use of `pre_execution_query`\"\n            raise ValueError(msg)\n        return _read_sql_adbc(\n            query,\n            connection_uri=uri,\n            schema_overrides=schema_overrides,\n            execute_options=execute_options,\n        )\n    else:\n        msg = f\"engine must be one of {{'connectorx', 'adbc'}}, got {engine!r}\"\n        raise ValueError(msg)\n","sourceCodeStart":503,"sourceCodeEnd":534,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/database/functions.py#L503-L534","documentation":"The adbc engine can execute only a single SQL statement per call, so `read_database_uri` validates that `query` is a plain str when engine=\"adbc\"; passing a list of queries (or any non-string) raises ValueError.","triggerScenarios":"Calling `read_database_uri([\"SELECT ...\", \"SELECT ...\"], uri, engine=\"adbc\")` or passing a non-string query with the adbc engine.","commonSituations":"Reusing list-of-queries code written for the connectorx engine (which accepts lists); batch-running multiple statements in one call.","solutions":["Call read_database_uri once per query string in your own loop.","Use engine=\"connectorx\" if you genuinely need multiple queries (it accepts a list).","Combine multiple SELECTs into one statement if the database supports it."],"exampleFix":"// before\npl.read_database_uri([q1, q2], uri, engine=\"adbc\")  # raises\n// after\nfor q in (q1, q2):\n    df = pl.read_database_uri(q, uri, engine=\"adbc\")","handlingStrategy":"validation","validationCode":"if engine == \"adbc\" and not isinstance(query, str):\n    raise ValueError(\"adbc accepts a single query string; loop over a list yourself\")","typeGuard":"def is_single_query(q) -> bool:\n    return isinstance(q, str)","tryCatchPattern":"queries = [query] if isinstance(query, str) else query\nif engine == \"adbc\":\n    dfs = [pl.read_database_uri(q, uri, engine=\"adbc\") for q in queries]\nelse:\n    dfs = [pl.read_database_uri(query, uri, engine=engine)]","preventionTips":["Normalize query input to a list of strings in your own wrapper, then branch per engine","Only pass lists of queries to the connectorx engine","Unit-test engine/query-shape combinations in CI"],"tags":["polars","adbc","sql","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}