Skip to main content

prepare

Function prepare 

Source
pub unsafe fn prepare(
    con: duckdb_connection,
    sql: &str,
) -> Result<PreparedStatement, ExtensionError>
Expand description

Prepares sql on con.

sql must hold exactly one statement; unlike query, a string with several is an error.

§Errors

Returns ExtensionError carrying DuckDB’s parse/bind error, or if sql contains an interior NUL byte.

An allocation failure inside DuckDB while it prepares a statement with parameters can leave its output pointing at a statement it has already freed, which this then reads and frees again; nothing on this side can tell. See docs/upstream-duckdb-reports.md, item 36.

§Safety

con must be a valid, open duckdb_connection.