Search code examples
pythonsqldatabasedbeaverduckdb

Open DuckDB database using Python and DBeaver


I created a DuckDB file using the following Python code:

import duckdb
con = duckdb.connect(database=':memory:')
con = duckdb.connect(database='db.duckdb', read_only=False)
con.execute("CREATE TABLE items(item VARCHAR, value DECIMAL(10,2), count INTEGER)")
con.execute("INSERT INTO items VALUES ('jeans', 20.0, 1), ('hammer', 42.2, 2)")
# Testing
# con.execute("SELECT * FROM items")
# print(con.fetchall())

This creates the files:

db.duckdb
db.duckdb.wal

How can I run queries on these files using DBeaver? I am stuck creating the connection and don't understand what is required to connect.

enter image description here


Solution

  • In the above image set:

    JDBC URL to: jdbc:duckdb:/home/<LOCAL_PATH>/db.duckdb
        Path to: /home/<LOCAL_PATH>/db.duckdb