feat: added examples_tutorials
This commit is contained in:
Executable
+22
@@ -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()
|
||||
Reference in New Issue
Block a user