{"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":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/io/database/functions.py","lineNumber":523,"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":505,"sourceCodeEnd":533,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/io/database/functions.py#L505-L533","documentation":"Raised by read_database_uri() when engine='adbc' and pre_execution_query is supplied. Setup statements before the main query are a connectorx-only feature (connectorx >= 0.4.2); the ADBC engine has no equivalent parameter.","triggerScenarios":"pl.read_database_uri(query, uri, engine='adbc', pre_execution_query='SET TIME ZONE ...').","commonSituations":"Engine-agnostic helper functions that always pass pre_execution_query; migrating from connectorx to adbc while keeping session-setup statements.","solutions":["Remove pre_execution_query when using engine='adbc'","Run setup statements separately over the same database before the adbc read (note adbc opens its own connection, so prefer server-side/session-scoped settings)","Use engine='connectorx' (>= 0.4.2) if you need pre_execution_query"],"exampleFix":"# before\npl.read_database_uri(q, uri, engine=\"adbc\", pre_execution_query=\"SET ROLE reader\")\n\n# after\npl.read_database_uri(q, uri, engine=\"adbc\")  # apply setup via the database/session instead","handlingStrategy":"validation","validationCode":"if engine == \"adbc\" and pre_execution_query:\n    pre_execution_query = None  # adbc does not support it","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep an engine-capabilities map in your helper (connectorx: pre_execution_query; adbc: execute_options)","Apply session setup outside the read when using adbc","Copy the pre_execution_query warning: the parameter is still unstable"],"tags":["database","adbc","engine","validation"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}