⌘K ctrl+k
Search Shortcut cmd + k | ctrl + k
DuckDB 2.0 ドキュメント 全文検索
per page, with , order by , clip by
Results of 1 - 10 of about 13 for cursor (0.002 sec.)
Python API 12686
Installation To use the DuckDB Python client, visit the Python installation page . The latest stable version of the DuckDB Python client is 2.0.0. Installation The DuckDB Python API can be installed using pip : pip install duckdb . Please s ... UseException saying connection is busy with another call; it refuses instead of waiting, so use a separate connection from cursor() . duckdb.sql() , the other functions of the duckdb module and duckdb.connect(":default:") all use one shared default con ... nection, so the same holds for them. To run queries in parallel, give each thread its own cursor: import threading import duckdb con = duckdb.connect() con.execute("CREATE TABLE numbers AS SELECT range AS n FROM range(1 ... 000)") def count_even(cursor, results): results.append(cursor.sql("SELECT count(*) FROM numbers WHERE n % 2 = 0").fetchall()) results = [] threads = [t ...
https://man.mtool.work/duckdb/2.0/clients/python/overview.html
Editing 11050
The linenoise-based CLI editor is available for macOS, Linux and Windows. DuckDB's CLI uses a line-editing library based on linenoise , which has shortcuts that are based on Emacs mode of readline . Below is a list of available commands. Yo ... next character. When buffer is empty, end editing Ctrl + H Delete previous character Ctrl + K Delete everything after the cursor Ctrl + T Swap character under cursor with previous character Ctrl + U Delete all text Ctrl + W Delete previous word Alt + ... ith previous word Alt + U Convert next word to uppercase Alt + Backspace Delete previous word Alt + \ Delete spaces around cursor Completing Key Action Tab Autocomplete. When autocompleting, cycle to next entry Shift + Tab When autocompleting, cycle to ... t with ; and execute it Ctrl + L Clear screen Ctrl + O Cancel editing of current query Ctrl + X Insert a newline after the cursor Ctrl + Q , then click Move cursor to mouse click position Ctrl + Z Suspend CLI and return to shell, use fg to re-open Exte ...
https://man.mtool.work/duckdb/2.0/clients/cli/editing.html
Python DB API 10275
The standard DuckDB Python API provides a SQL interface compliant with the DB-API 2.0 specification described by PEP 249 similar to the SQLite Python API . Connection To use the module, you must first create a DuckDBPyConnection object that ... efault connection con = duckdb.connect(database=":default:") You can open another connection to the same database with the cursor() method. A cursor has its own transaction and its own session settings, and cursors can run queries at the same time. A s ... call from another thread while it is busy raises a ResourceInUseException instead of waiting, so give each thread its own cursor. Closing a connection closes its cursors. See About cursor() for details. Connections are closed implicitly when they go o ... error, including reading a relation, register() and create_function() . Building a relation, the description property and cursor() still work, so a cursor can run other queries in the meantime. con.execute("SELECT * FROM items") con.sql("SELECT 42").f ...
https://man.mtool.work/duckdb/2.0/clients/python/dbapi.html
Write User Defined Functions 10047
Overview The Rust client can register user-defined functions written in Rust: scalar functions with the vscalar feature and table functions with the vtab feature. Both operate on DuckDB's columnar data chunks, so a single call processes a b ... ith get_parameter() , returning read-only bind data. init runs once before execution and returns per-scan state, such as a cursor. func produces one chunk of rows per call. It fills the output vectors and sets the chunk length. A length of 0 ends the s ... . struct NumbersBind { count: usize, } // Tracks scan progress: func is called once per output chunk. struct NumbersInit { cursor: AtomicUsize, } impl VTab for Numbers { type BindData = NumbersBind; type InitData = NumbersInit; fn bind(bind: &BindInfo) ... Ok(NumbersBind { count }) } fn init(_: &InitInfo) -> Result<Self::InitData, Box<dyn std::error::Error>> { Ok(NumbersInit { cursor: AtomicUsize::new(0) }) } fn func( func: &TableFunctionInfo<Self>, output: &mut DataChunkHandle, ) -> Result<(), Box<dyn s ...
https://man.mtool.work/duckdb/2.0/clients/rust/functions.html
Write User Defined Functions 9501
Overview The JDBC driver can register user-defined functions (UDFs) written in Java, including scalar functions and table functions. This page covers building and registering both, from the simple functional-interface overloads to the vecto ... ll up to that many rows, return how many you wrote, and DuckDB calls apply again for the next chunk until you return 0 . A cursor into the source therefore has to live in the init (or local-init) state so it survives across calls, rather than in a loca ... ); } @Override public long apply(DuckDBTableFunctionCallInfo info, DuckDBDataChunkWriter output) throws Exception { Series cursor = info.getInitData(); long row = 0; // Fill at most one chunk; DuckDB calls apply() again for the rest. for (; row < outpu ... t.capacity() && cursor.next < cursor.end; row++, cursor.next++) { for (long col = 0; col < output.columnCount(); col++) { DuckDBWritableVector ve ...
https://man.mtool.work/duckdb/2.0/clients/java/functions.html
Multiple Python Threads 8745
This page demonstrates how to simultaneously insert into and read from a DuckDB database across multiple Python threads. This could be useful in scenarios where new data is flowing in and an analysis should be periodically re-run. Note that ... der and Writer Functions Next, define functions to be executed by the writer and reader threads. Each thread must use the .cursor() method to create a thread-local connection to the same DuckDB file based on the original connection. This approach also ... iting. def write_from_thread(duckdb_con): # Create a DuckDB connection specifically for this thread local_con = duckdb_con.cursor() # Insert a row with the name of the thread. insert_time is auto-generated. thread_name = str(current_thread().name) resu ... chall() def read_from_thread(duckdb_con): # Create a DuckDB connection specifically for this thread local_con = duckdb_con.cursor() # Query the current row count thread_name = str(current_thread().name) results = local_con.execute(""" SELECT ? AS threa ...
https://man.mtool.work/duckdb/2.0/guides/python/multiple_threads.html
Integration with PyTorch 8305
PyTorch tensors can be built from DuckDB query results by exporting each result batch as Apache Arrow . This pattern is useful when training or serving models on Parquet data because DuckDB can filter and project the input before the batche ... he loop holds the reader, other queries on con raise a ResourceInUseException ; a loop that runs a query per batch needs a cursor from con.cursor() . To get the whole result at once, the torch() method of a relation returns a dictionary with one tensor ...
https://man.mtool.work/duckdb/2.0/guides/python/pytorch.html
Python Function API 7865
You can create a DuckDB user-defined function (UDF) from a Python function so it can be used in SQL queries. Similarly to regular functions , they need to have a name, a return type and parameter types. Creating Functions To register a Pyth ... ion: Resource In Use Error: code running inside a query cannot use that query's connection; use a separate connection from cursor() . A cursor of that connection works: def lookup(x: int) -> int: cur = con.cursor() try: return cur.execute("SELECT 41 + ...
https://man.mtool.work/duckdb/2.0/clients/python/function.html
Export to Apache Arrow 7865
All results of a query can be exported to an Apache Arrow Table using the to_arrow_table function. Alternatively, results can be returned as a RecordBatchReader using the to_arrow_reader function and results can be read one batch at a time. ... ts connection raise a ResourceInUseException . Read the reader to the end or close it first, or run the other queries on a cursor from con.cursor() . Deprecated On relations, fetch_arrow_table , fetch_record_batch and fetch_arrow_reader are deprecated ...
https://man.mtool.work/duckdb/2.0/guides/python/export_arrow.html
Run Queries 7425
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 ... () log.Fatal(err) } if err := tx.Commit(); err != nil { log.Fatal(err) } Scanning Results QueryContext returns a *sql.Rows cursor. Advance it with Next() , read the current row's columns into pointers with Scan() , and always check Err() after the loop ... and close the cursor. Scan matches columns to the destination Go types by position: rows, err := db.QueryContext(ctx, `SELECT name, age FROM us ...
https://man.mtool.work/duckdb/2.0/clients/go/querying.html
PREV 1 2 NEXT
DuckDB 2.0 Documentation / man.mtool.work