Execute SQL
Version 0.3.3

How to execute SQL queries

First connect to a database using the connect command. By default an in-memory database will be opened.

import duckdb
con = duckdb.connect()

After connecting, SQL queries can be executed using the execute command.

results = con.execute("SELECT 42").fetchall()

By default, a list of Python objects is returned. Use df if you would like the result to be returned as a Python dataframe instead.

results = con.execute("SELECT 42").df()
Search Shortcut cmd + k | ctrl + k