Home

Awesome

vduckdb 0.6.5

A V wrapper for duckdb. This library is now in beta and should be safe to use in most scenarios. Should work on Linux, Windows and MacOS with V version 0.4.x

DuckDB Libraries installation

vduckdb installation

v install https://github.com/rodabt/vduckdb

Main usage

// file.v
import vduckdb

fn main() {
    
    mut db := vduckdb.DuckDB{}
    println('vduckdb version: ${vduckdb.version()}')
    println('duckdb version: ${vduckdb.duckdb_library_version()}')

    _ := db.open(':memory:')!

    mut q := 'select "Index", "First Name", "Last Name", "Email", "Date of birth" from \'people-100.csv\' limit 10'
    println('\nQuery: ${q}')

    _ := db.query(q)!

    println('\nColumns and types: ${db.columns}')
    
    println('\n Results as table to terminal:')
    println(db.print_table(max_rows: 10, mode: 'box'))

    q = 'select "First Name", "Sex" from \'people-100.csv\' limit 5'
    println('\nData from \'${q}\' as []map[string]string:')
    _ := db.query(q)!
    out := db.get_array_as_string()
    println(out)

    first_row := db.get_first_row()
    println(first_row)

    println('\nManaging errors...')
    q = "select sdkf fff f"
    db.query(q) or {
      eprintln(err.msg())
    }

    defer {
      db.close()
    }

}
# If you have `thirdparty` directory and its contents in the same directory as `file.v`
v run file.v

# Otherwise
LIBDUCKDB_DIR=/my/custom/libduckdb/directory v run file.v

Documentation

Run v doc vduckdb or make docs to generate static HTML documentation in docs folder

Roadmap

Contributing

Pull requests are welcome