feat: added examples_tutorials

This commit is contained in:
xpk
2025-11-26 23:20:41 +08:00
parent 96ef5cb42e
commit 9d044c20c9
16 changed files with 201 additions and 70 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env python3
import duckdb
# Create an in-memory DuckDB connection
con = duckdb.connect(':memory:')
# first query which selects a number
r1 = con.sql("SELECT 42 AS i")
con.sql("SELECT i * 2 AS k FROM r1").show()
# create a table. insert a row and query the table
con.sql("CREATE TABLE test (i INTEGER)")
con.sql("INSERT INTO test VALUES (42)")
con.table("test").show()
# read a csv into duckdb
csvt = con.read_csv("duck.csv")
con.sql("SELECT * FROM csvt WHERE name = 'tom'").show()
# explicitly close the connection
con.close()