-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdatabase.py
More file actions
32 lines (21 loc) · 781 Bytes
/
database.py
File metadata and controls
32 lines (21 loc) · 781 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import duckdb
# duckdb.sql("SELECT 42").show()
con = duckdb.connect("air_quality.db")
df = con.table("air_quality").to_df()
print(df)
print(con.execute("SHOW TABLES").fetchall())
con.sql(
"CREATE TABLE IF NOT EXISTS users (username VARCHAR, age INTEGER, country VARCHAR)"
)
con.table("users").show()
con.close()
# with duckdb.connect("air_quality.db") as con:
# df = con.table("air_quality").to_df()
# print(df)
# # create folder
# con2 = duckdb.connect("air_quality.db")
# print(con2.execute("SHOW TABLES").fetchall())
# con.sql("CREATE TABLE users (username VARCHAR, age INTEGER, country VARCHAR)")
# con.table("users").show()
# con2.sql("CREATE TABLE IF NOT EXISTS users (username VARCHAR, age INTEGER, country VARCHAR)")
# con2.table("users").show()