Results of 1 - 10 of about 16 for printf (0.004 sec.)
- Text Functions 12407
- Text Functions and Operators This section describes functions and operators for examining and manipulating STRING values . Function Description string[index] Extracts a single character using a (1-based) index . string[begin:end] Extracts a
...(string, search_string) Alias for instr . prefix(string, search_string) Returns true if string starts with search_string . printf(format, ...) Formats a string using printf syntax . read_text(source) Returns the content from source (a filename, a list...) | Description | Returns true if string starts with search_string . | | Example | prefix('abc', 'ab') | | Result | true | printf(format, ...) | Description | Formats a string using printf syntax . | | Example | printf('Benchmark "%s" took %d seconds',...-- 123,456.789000 SELECT format('{:,.2f}', 123456.789); -- 123,456.79 SELECT format('{:t..2f}', 123456.789); -- 123.456,79 printf Syntax The printf(format, parameters...) function formats strings using the printf syntax . Format without additional para... - https://man.mtool.work/duckdb/2.0/sql/functions/text.html
- Vectors 11852
- Vectors represent a horizontal slice of a column. They hold a number of values of a specific type, similar to an array. Vectors are the core data representation used in DuckDB. Vectors are typically stored within data chunks . The vector an
...rate over the rows for (idx_t row = 0; row < row_count; row++) { if (duckdb_validity_row_is_valid(vector_validity, row)) { printf("%lld\n", vector_data[row]); } else { printf("NULL\n"); } } duckdb_destroy_data_chunk(&result); } // clean-up duckdb_destr...ector_validity, row)) { duckdb_string_t str = vector_data[row]; if (duckdb_string_is_inlined(str)) { // use inlined string printf("%.*s\n", str.value.inlined.length, str.value.inlined.inlined); } else { // follow string pointer printf("%.*s\n", str.val...ue.pointer.length, str.value.pointer.ptr); } } else { printf("NULL\n"); } } duckdb_destroy_data_chunk(&result); } // clean-up duckdb_destroy_result(&res); duckdb_disconnect(&con); duc... - https://man.mtool.work/duckdb/2.0/clients/c/vector.html
- Query 11384
- The duckdb_query method allows SQL queries to be run in DuckDB from C. This method takes two parameters, a (null-terminated) SQL query string and a duckdb_result result pointer. The result pointer may be NULL if the application is not inter
...terate over the rows for (idx_t row = 0; row < row_count; row++) { if (duckdb_validity_row_is_valid(col1_validity, row)) { printf("%d", col1_data[row]); } else { printf("NULL"); } printf(","); if (duckdb_validity_row_is_valid(col2_validity, row)) { pri...ntf("%d", col2_data[row]); } else { printf("NULL"); } printf("\n"); } duckdb_destroy_data_chunk(&result); } // clean-up duckdb_destroy_result(&res); duckdb_disconnec...ount(&result); for (idx_t row = 0; row < row_count; row++) { for (idx_t col = 0; col < column_count; col++) { if (col > 0) printf(","); auto str_val = duckdb_value_varchar(&result, col, row); printf("%s", str_val); duckdb_free(str_val); } printf("\n");... - https://man.mtool.work/duckdb/2.0/clients/c/query.html
- Sharing Macros 10033
- DuckDB has a powerful macro mechanism that allows creating shorthands for common tasks. Sharing a Scalar Macro First, we define a macro that pretty-prints a non-negative integer as a short string with thousands, millions, and billions (with
...ollows: duckdb pretty_print_integer_macro.duckdb CREATE MACRO pretty_print_integer(n) AS CASE WHEN n >= 1_000_000_000 THEN printf('%dB', n // 1_000_000_000) WHEN n >= 1_000_000 THEN printf('%dM', n // 1_000_000) WHEN n >= 1_000 THEN printf('%dk', n //...1_000) ELSE printf('%d', n) END; SELECT pretty_print_integer(25_500_000) AS x; ┌─────────┐ │ x │ │ varchar │ ├─────────┤ │ 25M │ └─────────┘... - https://man.mtool.work/duckdb/2.0/guides/snippets/sharing_macros.html
- Calculating a Database Checksum 9010
- To calculate a database checksum, use a commutative operation such as bit_xor on all columns, all rows, and all tables. First, create a table macro that performs this for each table: CREATE OR REPLACE MACRO table_checksum(table_name) AS TAB
...the CLI, you can do so by dynamically generating a SQL file: .mode list .headers off .once checksum_all_tables.sql SELECT printf('CREATE OR REPLACE TABLE table_checksums (checksum UHUGEINT);') UNION ALL SELECT printf('INSERT INTO table_checksums FROM... - https://man.mtool.work/duckdb/2.0/guides/snippets/database_checksum.html
- Run Queries 8854
- 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
....ExecContext(ctx, `INSERT INTO users VALUES ('marc', 99)`) if err != nil { log.Fatal(err) } n, _ := res.RowsAffected() log.Printf("inserted %d rows", n) Binding Parameters Values are bound to a statement's placeholders rather than formatted into the SQ....Close() for rows.Next() { var ( name string age int ) if err := rows.Scan(&name, &age); err != nil { log.Fatal(err) } log.Printf("%s is %d years old", name, age) } if err := rows.Err(); err != nil { log.Fatal(err) } When the column set is not known ah...e[[]any] row := db.QueryRow(`SELECT json_array('foo', 'bar')`) if err := row.Scan(&arr); err != nil { log.Fatal(err) } log.Printf("first element: %s", arr.Get()[0]) // A JSON object (or STRUCT) value read into a map. var obj duckdb.Composite[map[string... - https://man.mtool.work/duckdb/2.0/clients/go/querying.html
- Profile and Monitor 8213
- Overview The Go client can observe query execution: it can retrieve per-operator profiling metrics after a query runs, and register a log storage that receives DuckDB's log messages. Both are described below. Profiling Profiling information
..._time . Walk the tree to read them: for _, child := range info.Children { if opType, ok := child.Metrics["type"]; ok { log.Printf("operator: %s, timing: %s", opType, child.Metrics["timing"]) } } All metrics are collected by default; to restrict them, s...rage(connector, "my_log_storage", duckdb.LoggerCallbacks{ DefaultLoggerCallback: func(level, logType, logMsg string) { log.Printf("[%s] %s: %s", level, logType, logMsg) }, }) check(err) // Enable logging, then point it at the registered storage. db :=... - https://man.mtool.work/duckdb/2.0/clients/go/profiling.html
- Handle Results 7589
- Overview DuckDB is columnar, and beyond reading a result set row by row through database/sql , the Go client can exchange whole results with Apache Arrow as a stream of record batches, and register an Arrow stream as a queryable view. Both
...rr) } defer reader.Release() for reader.Next() { record := reader.RecordBatch() // Process one record batch at a time. log.Printf("%d rows", record.NumRows()) } if err := reader.Err(); err != nil { log.Fatal(err) } QueryContext() accepts bound paramete... - https://man.mtool.work/duckdb/2.0/clients/go/result_handling.html
- Python Client API 7503
- 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
...arse_path', 0, ['VARCHAR']), 'path_join': ('path_join', 0, ['VARCHAR']), 'prefix': ('prefix', 0, ['VARCHAR', 'VARCHAR']), 'printf': ('printf', 0, ['VARCHAR']), 'regexp_escape': ('regexp_escape', 0, ['VARCHAR']), 'regexp_extract': ('regexp_extract', 0,...gs : ValueOrExpr ) → Expression Returns true if string starts with search_string . Arguments: search_string. SQL: prefix . printf ( * args : ValueOrExpr ) → StrExpr Formats a string using printf syntax. SQL: printf . regexp_escape ( * args : ValueOrExp... - https://man.mtool.work/duckdb/2.0/clients/python/reference/
- Importing Duckbox Tables 7503
- The scripts provided in this page work on Linux, macOS, and WSL. By default, the DuckDB CLI client renders query results in the duckbox format , which uses rich, ASCII-art inspired tables to show data. These tables are often shared verbatim
...duckbox.csv) |', delim = '│' ); We can also create a table macro : CREATE MACRO read_duckbox(path) AS TABLE FROM read_csv( printf( '(sed -n "2s/^│ *//;s/ *│$//;s/ *│ */│/p;2q" %s; ' || 'sed "1,4d;\$d;s/^│ *//;s/ *│$//;s/ *│ */│/g" %s) |', path, path ),... - https://man.mtool.work/duckdb/2.0/guides/snippets/importing_duckbox_tables.html
DuckDB 2.0 Documentation / man.mtool.work