⌘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 73 for Execute (0.003 sec.)
Python DB API 12967
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 ... on The duckdb module has a default connection to an unnamed in-memory database . Functions such as duckdb.sql() and duckdb.execute() use the default connection; the first function that needs it creates it. Some module functions differ from connection me ... e special value :default: and the duckdb.default_connection() function return the default connection: import duckdb duckdb.execute("CREATE TABLE tbl AS SELECT 42 AS a") con = duckdb.connect(":default:") con.sql("SELECT * FROM tbl") # or duckdb.default_c ... r connection the default connection, pass it to duckdb.set_default_connection() : import duckdb con = duckdb.connect() con.execute("CREATE TABLE answer AS SELECT 42 AS a") duckdb.set_default_connection(con) duckdb.sql("SELECT * FROM answer").fetchall() ...
https://man.mtool.work/duckdb/2.0/clients/python/dbapi.html
PREPARE, EXECUTE, and DEALLOCATE Statements 10731
The PREPARE statement creates a prepared statement for later execution. The EXECUTE statement runs it with optional arguments. The DEALLOCATE statement removes it. For details about auto-incremented, positional, and named parameters, see Pr ... person : PREPARE query_person AS SELECT * FROM person WHERE starts_with(name, $name_start) AND age >= $minimum_age; Syntax EXECUTE Execute a prepared statement with named arguments: EXECUTE query_person(name_start := 'B', minimum_age := 40); Execute a p ... repared statement with positional arguments: EXECUTE add_values(20, 22); Syntax DEALLOCATE Remove a prepared statement: DEALLOCATE query_person; The optional PREPARE keyword i ...
https://man.mtool.work/duckdb/2.0/sql/statements/prepare.html
Run Queries 10214
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 ... rs, and turning rows into typed Rust values. For opening the Connection these run on, see Connect . Sending Statements Use execute() for a single statement that does not return rows, such as INSERT or UPDATE . It takes the SQL and a list of parameters, ... and returns the number of affected rows. Pass an empty slice [] when there are no parameters: conn.execute( "CREATE TABLE person (id INTEGER, name TEXT, data BLOB)", [], )?; let rows_changed = conn.execute( "INSERT INTO person (i ... d, name) VALUES (1, 'Steven')", [], )?; To run several statements at once, for example a schema-setup script, use execute_batch() : conn.execute_batch( r"CREATE SEQUENCE seq; CREATE TABLE person ( id INTEGER PRIMARY KEY DEFAULT NEXTVAL('seq'), ...
https://man.mtool.work/duckdb/2.0/clients/rust/querying.html
Migrating Python Code to DuckDB 2.0 9879
This page lists what Python code written for DuckDB 1.x must change to run on DuckDB 2.0. Each item gives the 1.x form, the 2.0 form and the page that explains it. For changes outside the Python client, see Migrating to DuckDB v2.0 . Python ... re not supported. On Python 3.10, pip install duckdb installs a 1.x release. See Installation . Arrow and Polars output of execute() . 1.x: con.execute(query).fetch_arrow_table() , fetch_record_batch() , arrow() and pl() . 2.0: these methods are gone fr ... om execute() results, and to_arrow_table() and to_arrow_reader() there copy the rows and warn. Use a relation: con.sql(query).to_arro ... con.sql(query).pl() . See Arrow and Polars Output . Fetching from a relation. 1.x: rel.fetchone() , rel.fetchmany(n) , rel.execute() and rel.fetch_df_chunk() . 2.0: these methods are gone, because a relation keeps no result between calls and runs its qu ...
https://man.mtool.work/duckdb/2.0/clients/python/migration.html
Julia Client 9711
The DuckDB Julia package provides a high-performance front-end for DuckDB. Much like SQLite, DuckDB runs in-process within the Julia client, and provides a DBInterface front-end. The package also supports multi-threaded execution. It uses J ... ing DuckDB # create a new in-memory database con = DBInterface.connect(DuckDB.DB, ":memory:") # create a table DBInterface.execute(con, "CREATE TABLE integers (i INTEGER)") # insert data by executing a prepared statement stmt = DBInterface.prepare(con, ... "INSERT INTO integers VALUES (?)") DBInterface.execute(stmt, [42]) # query the database results = DBInterface.execute(con, "SELECT 42 a") print(results) Some SQL statements, suc ... h as PIVOT and IMPORT DATABASE are executed as multiple prepared statements and will error when using DuckDB.execute() . Instead they can be run with DuckDB.query() ...
https://man.mtool.work/duckdb/2.0/clients/tertiary_clients/julia.html
SQL to/from JSON 9362
DuckDB provides functions to serialize and deserialize SELECT statements between SQL and JSON, as well as executing JSON serialized statements. Function Type Description json_deserialize_sql(json) Scalar Deserialize one or many json seriali ... zed statements back to an equivalent SQL string. json_execute_serialized_sql(varchar) Table Execute json serialized statements and return the resulting rows. Only one statement at a ti ... lize a set of semicolon-separated ( ; ) select statements to an equivalent list of json serialized statements. PRAGMA json_execute_serialized_sql(varchar) Pragma Pragma version of the json_execute_serialized_sql function. The json_serialize_sql(varchar) ... skip_empty , skip_null and format that can be used to control the output of the serialized statements. If you run the json_execute_serialized_sql(varchar) table function inside of a transaction the serialized statements will not be able to see any trans ...
https://man.mtool.work/duckdb/2.0/data/json/sql_to_and_from_json.html
Python Client API 9138
Connection class duckdb. Appender Bases: object append_row ( self , * args ) → None Buffer one row, one value per column, each converted as an executemany parameter would be append_rows ( self , rows : object ) → None Buffer each row of an ... ppender's connection class duckdb. DuckDBPyConnection Bases: object abort ( self ) → None Cancel the rest of the result of execute(); a statement that may write fails an open transaction append ( self , table_name : str , df : object , * , by_name : boo ... lf ) → _duckdb.DuckDBPyConnection Commit changes performed within a transaction complete ( self ) → None Run the result of execute() to its end without reading its rows create_function ( self , name : str , function : collections.abc.Callable , paramete ... ibutes, mainly column names df ( self , * , date_as_object : bool = False ) → object Fetch a result as DataFrame following execute() disable_profiling ( self ) → None Disable profiling for subsequent queries dtype ( self , type_str : str ) → _duckdb._sq ...
https://man.mtool.work/duckdb/2.0/clients/python/reference/
Conversion between DuckDB and Python 9013
This page documents the rules for converting DuckDB results to Python and Python objects to DuckDB . Result Conversion: DuckDB Results to Python A result is read from a relation or, when using the DB-API / con.execute() , from the connectio ... the readers and the other relational methods return relations. Each has its own methods: Result Relation DB-API 2.0 ( con.execute() ) Python tuples fetchall() , iter_rows(batch_size=1024) fetchone() , fetchmany(size=1) , fetchall() Python dicts to_dict ... me examples. See the Python guides for more. To run the examples, use this table: import duckdb con = duckdb.connect() con.execute("CREATE TABLE items (item VARCHAR, value DECIMAL(10, 2), count INTEGER)") con.execute(""" INSERT INTO items VALUES ('jeans ... ', 42.2, 2), ('laptop', 2000.0, 1), ('chainsaw', 500.0, 10), ('iphone', 300.0, 2) """) Fetch as Pandas DataFrame: df = con.execute("SELECT * FROM items").df() print(df) item value count 0 jeans 20.0 1 1 hammer 42.2 2 2 laptop 2000.0 1 3 chainsaw 500.0 1 ...
https://man.mtool.work/duckdb/2.0/clients/python/conversion.html
Appender 8677
Use an appender to insert rows that your Python code produces. It collects rows and writes them together in one SQL statement; this is called flushing. The with block below flushes on successful exit: import duckdb con = duckdb.connect() co ... n.execute("CREATE TABLE people (id INTEGER PRIMARY KEY, name VARCHAR)") with con.appender("people") as appender: appender.append_row ... olumns. append_row takes one value per column, and append_rows takes any iterable of rows. Values are converted exactly as executemany parameters are. To append to some of the columns, list them in columns . The other columns take their default value, p ... er row: con.execute("CREATE SEQUENCE event_ids") con.execute( "CREATE TABLE events (id INTEGER DEFAULT nextval('event_ids'), kind VARCHAR, not ...
https://man.mtool.work/duckdb/2.0/clients/python/appender.html
Prepared Statements 8565
DuckDB supports prepared statements where parameters are substituted when the query is executed. This can improve readability and is useful for preventing SQL injections . Syntax There are three syntaxes for denoting parameters in prepared ... EPARE query_person AS SELECT * FROM person WHERE starts_with(name, ?) AND age >= ?; Using the CLI client, the statement is executed as follows. EXECUTE query_person('B', 40); Positional Parameters: $1 Prepared statements can use positional parameters, w ... ARE query_person AS SELECT * FROM person WHERE starts_with(name, $2) AND age >= $1; Using the CLI client, the statement is executed as follows. Note that the first parameter corresponds to $1 , the second to $2 , and so on. EXECUTE query_person(40, 'B') ... * FROM person WHERE starts_with(name, $name_start_letter) AND age >= $minimum_age; Using the CLI client, the statement is executed as follows. EXECUTE query_person(name_start_letter := 'B', minimum_age := 40); Session Variables as Default Values New Us ...
https://man.mtool.work/duckdb/2.0/sql/query_syntax/prepared_statements.html
PREV 1 2 3 4 5 6 7 8 NEXT
DuckDB 2.0 Documentation / man.mtool.work