Results of 1 - 10 of about 19 for stmt (0.002 sec.)
- Run Queries 12823
- Overview Java applications send queries and read result sets through the familiar Statement , PreparedStatement , and ResultSet interfaces. This page covers sending queries and reading DuckDB's nested and composite types. For opening the Co
...Set; import java.sql.Statement; Connection conn = DriverManager.getConnection("jdbc:duckdb:"); // create a table Statement stmt = conn.createStatement(); stmt.execute("CREATE TABLE items (item VARCHAR, value DECIMAL(10, 2), count INTEGER)"); // inser...t two items into the table stmt.execute("INSERT INTO items VALUES ('jeans', 20.0, 1), ('hammer', 42.2, 2)"); try (ResultSet rs = stmt.executeQuery("SELECT...* FROM items")) { while (rs.next()) { System.out.println(rs.getString(1)); System.out.println(rs.getInt(3)); } } stmt.close(); jeans 1 hammer 2 DuckDB also supports prepared statements as per the JDBC API: import java.sql.PreparedStatement;... - https://man.mtool.work/duckdb/2.0/clients/java/querying.html
- Import Data 12225
- Overview The JDBC driver offers two ways to load data into DuckDB in bulk: the high-performance Appender and a JDBC batch writer. This page describes both and when to use each. Appender The Appender is available in the DuckDB JDBC driver vi
....duckdb.DuckDBConnection; DuckDBConnection conn = (DuckDBConnection) DriverManager.getConnection("jdbc:duckdb:"); try (var stmt = conn.createStatement()) { stmt.execute("CREATE TABLE tbl (x INTEGER, y DOUBLE, s VARCHAR)"); // using try-with-resources...uckDBConnection; DuckDBConnection conn = (DuckDBConnection) DriverManager.getConnection("jdbc:duckdb:"); PreparedStatement stmt = conn.prepareStatement("INSERT INTO test (x, y, z) VALUES (?, ?, ?);"); stmt.setObject(1, 1); stmt.setObject(2, 2); stmt....setObject(3, 3); stmt.addBatch(); stmt.setObject(1, 4); stmt.setObject(2, 5); stmt.setObject(3, 6); stmt.addBatch(); stmt.executeBatch(); stmt.c... - https://man.mtool.work/duckdb/2.0/clients/java/data_import.html
- ODBC 101: A Duck Themed Guide to ODBC 10654
- What is ODBC? ODBC which stands for Open Database Connectivity, is a standard that allows different programs to talk to different databases including, of course, DuckDB. This makes it easier to build programs that work with many different d
..., and then used once the connection has been established. | Statement | Handle name | Statement | | Type name | SQL_HANDLE_STMT | | Description | Handles the execution of SQL statements, as well as the returned result sets. | | Use case | Executing S...ery Now that the application is set up, we can add a query to it. First, we need to allocate a statement handle: SQLHANDLE stmt; SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt); Then we can execute a query: SQLExecDirect(stmt, (SQLCHAR*)"SELECT * FROM in...the results. First, we need to bind the columns in the result set to buffers: SQLLEN int_val; SQLLEN null_val; SQLBindCol(stmt, 1, SQL_C_SLONG, &int_val, 0, &null_val); Then we can fetch the results: SQLFetch(stmt); 5. Process the Results Now that w... - https://man.mtool.work/duckdb/2.0/guides/odbc/general.html
- Connect 10108
- Overview Every DuckDB feature reachable from Java starts with a Connection . This page covers the JDBC URL forms the driver accepts, how DuckDB and driver options are passed and which of them win, how connections come to share (or not share
...tion also needs a local database of its own: try (Connection conn = DriverManager.getConnection("jdbc:duckdb:"); Statement stmt = conn.createStatement()) { stmt.execute("ATTACH 'ducklake:metadata.ducklake' AS lake (DATA_PATH 'lake_files/')"); stmt.ex...ecute("USE lake"); stmt.execute("CREATE TABLE IF NOT EXISTS events (id INTEGER, payload VARCHAR)"); stmt.execute("INSERT INTO events VALUES (1, 'h...ello'), (2, 'world')"); try (ResultSet rs = stmt.executeQuery("SELECT count(*) FROM events")) { rs.next(); System.out.println(rs.getLong(1)); } } The ducklake extension is... - https://man.mtool.work/duckdb/2.0/clients/java/connecting.html
- Prepared Statements 9186
- A prepared statement is a parameterized query. The query is prepared with question marks ( ? ) or dollar symbols ( $1 ) indicating the parameters of the query. Values can then be bound to these parameters, after which the prepared statement
...ith the prepared statement it can be cleaned up using the duckdb_destroy_prepare method. Example duckdb_prepared_statement stmt; duckdb_result result; if (duckdb_prepare(con, "INSERT INTO integers VALUES ($1, $2)", &stmt) == DuckDBError) { // handle...error } duckdb_bind_int32(stmt, 1, 42); // the parameter index starts counting at 1! duckdb_bind_int32(stmt, 2, 43); // NULL as second parameter means no...result set is requested duckdb_execute_prepared(stmt, NULL); duckdb_destroy_prepare(&stmt); // we can also query result sets using prepared statements if (duckdb_prepare(con,... - https://man.mtool.work/duckdb/2.0/clients/c/prepared.html
- Handle Results 8862
- Overview Beyond reading a result set row by row , the Rust client can hand a query result to Apache Arrow as a stream of record batches, register an Arrow batch as a queryable table, and return results as Polars data frames. Each of these c
...cord_batch::RecordBatch; use duckdb::arrow::util::pretty::print_batches; let conn = Connection::open_in_memory()?; let mut stmt = conn.prepare("SELECT * FROM generate_series(1, 5)")?; let batches: Vec<RecordBatch> = stmt.query_arrow([])?.collect(); p...consumed lazily, fetching chunks only as the iterator advances, use stream_arrow() , which is otherwise identical: let mut stmt = conn.prepare("SELECT * FROM big_table")?; for batch in stmt.stream_arrow([])? { // process one RecordBatch at a time pri...chunk: use duckdb::{Connection, Result}; use polars::prelude::DataFrame; let conn = Connection::open_in_memory()?; let mut stmt = conn.prepare("SELECT * FROM test")?; let dfs: Vec<DataFrame> = stmt.query_polars([])?.collect(); To combine the chunks i... - https://man.mtool.work/duckdb/2.0/clients/rust/result_handling.html
- Run Queries 8810
- Overview A Connection runs SQL through two families of methods: The execute_* methods ( execute() and execute_batch() ) send statements that do not return rows, such as INSERT or DDL, and report the number of affected rows. The query_* meth
...can be executed repeatedly. The returned Statement can be executed with execute() , or queried to read rows back. let mut stmt = conn.prepare("INSERT INTO person (id, name) VALUES (?, ?)")?; stmt.execute(params![1, "Steven"])?; stmt.execute(params![...ich can be collected into a Vec : #[derive(Debug)] struct Person { id: i32, name: String, data: Option<Vec<u8>>, } let mut stmt = conn.prepare("SELECT id, name, data FROM person")?; let people = stmt .query_map([], |row| { Ok(Person { id: row.get(0)?...e::Enum , and Value::Decimal , so a query that selects nested columns can be matched on: use duckdb::types::Value; let mut stmt = conn.prepare("SELECT [1, 2, 3] AS l, {'a': 1, 'b': 2} AS s")?; let mut rows = stmt.query([])?; while let Some(row) = row... - https://man.mtool.work/duckdb/2.0/clients/rust/querying.html
- Run Queries 8213
- Overview DuckDB-Wasm provides functions for querying data. Queries are run sequentially: First, create a connection by calling connect . Then, run queries by calling query to materialize the whole result, or send to fetch result chunks lazi
...available on a prepared statement: // Create a new connection const conn = await db.connect(); // Prepare the query const stmt = await conn.prepare(`SELECT v + ? FROM generate_series(0, 10_000) t(v);`); // ... and run it with materialized results aw...ait stmt.query(234); // ... or as result chunks for await (const batch of await stmt.send(234)) { // ... } // Close the statement t...o release memory await stmt.close(); // Closing the connection releases its statements as well await conn.close(); Arrow Table to JSON Query results a... - https://man.mtool.work/duckdb/2.0/clients/wasm/query.html
- Handle Results 7940
- Overview Beyond the standard JDBC ResultSet , the DuckDB driver can hand results to Apache Arrow , stream large results instead of materializing them, and expose raw columnar data chunks. This page covers each of these result-handling optio
...ector.ipc.ArrowReader; import org.duckdb.DuckDBResultSet; try (var conn = DriverManager.getConnection("jdbc:duckdb:"); var stmt = conn.prepareStatement("SELECT * FROM generate_series(2000)"); var resultset = (DuckDBResultSet) stmt.executeQuery(); var...iverManager.getConnection("jdbc:duckdb:")) { conn.registerArrowStream("asdf", arrow_array_stream); // run a query try (var stmt = conn.createStatement(); var rs = (DuckDBResultSet) stmt.executeQuery("SELECT count(*) FROM asdf")) { while (rs.next()) {... - https://man.mtool.work/duckdb/2.0/clients/java/result_handling.html
- Run Queries 7752
- Overview Because the Go client implements database/sql , queries run through the standard methods: Exec and ExecContext send statements that do not return rows, such as INSERT or DDL, and report the number of affected rows. Query , QueryCon
...b.PrepareContext() compiles a statement once so it can be executed many times, which pays off in a loop. The returned *sql.Stmt has its own Exec and Query methods, and must be closed when no longer needed: stmt, err := db.PrepareContext(ctx, `INSERT...INTO users VALUES (?, ?)`) if err != nil { log.Fatal(err) } defer stmt.Close() for _, u := range users { if _, err := stmt.ExecContext(ctx, u.name, u.age); err != nil { log.Fatal(err) } } Trans... - https://man.mtool.work/duckdb/2.0/clients/go/querying.html
DuckDB 2.0 Documentation / man.mtool.work