{"record":{"id":"5015e475df8ea1b7","repo":"pola-rs/polars","slug":"the-adbc-engine-does-not-support-use-of-pre-exe","errorCode":null,"errorMessage":"the 'adbc' engine does not support use of `pre_execution_query`","messagePattern":"the 'adbc' engine does not support use of `pre_execution_query`","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/database/functions.py","lineNumber":524,"sourceCode":"                \"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":506,"sourceCodeEnd":534,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/io/database/functions.py#L506-L534","documentation":"read_database_uri with engine='adbc' refuses the pre_execution_query parameter because the ADBC driver API only executes a single statement per connection, so polars cannot run a secondary query before the main one. connectorx supports it; adbc does not.","triggerScenarios":"Calling pl.read_database_uri(query, uri, engine='adbc', pre_execution_query='SET ...') with any truthy pre_execution_query string.","commonSituations":"Users porting connectorx-based code to adbc while keeping session-setup queries (e.g. SET timezone, USE schema) that were needed for the other engine.","solutions":["Remove pre_execution_query and execute setup statements separately before calling read_database_uri","Switch engine to 'connectorx' which supports pre_execution_query","Embed the setup (e.g. schema qualification) directly into the main SQL query string"],"exampleFix":"// before\npl.read_database_uri('SELECT * FROM t', uri, engine='adbc', pre_execution_query='SET timezone=UTC')\n// after\npl.read_database_uri(\"SET timezone=UTC; SELECT * FROM t\", uri, engine='adbc')  # if driver allows, or run setup via a separate connection","handlingStrategy":"validation","validationCode":"if engine == 'adbc' and pre_execution_query:\n    raise ValueError('pre_execution_query is not supported with engine=adbc')","typeGuard":null,"tryCatchPattern":"try:\n    df = pl.read_database_uri(q, uri, engine='adbc', pre_execution_query=setup)\nexcept ValueError as e:\n    if 'pre_execution_query' in str(e):\n        df = pl.read_database_uri(q, uri, engine='connectorx', pre_execution_query=setup)","preventionTips":["Never pass pre_execution_query together with engine='adbc'","Inline session setup into the main SQL string where the driver allows multiple statements","Run setup statements on a separate connection before the read"],"tags":["python","polars","database","adbc","invalid-argument"],"backgroundTag":"conflicting-config-options","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"}