-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.py
More file actions
executable file
·83 lines (72 loc) · 1.88 KB
/
dev.py
File metadata and controls
executable file
·83 lines (72 loc) · 1.88 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = "==3.13"
# dependencies = [
# "ibis-framework[bigquery,duckdb,postgres,sqlite]",
# "ipython",
# "pandas",
# "plotly",
# "polars",
# "rich",
# "typer",
# ]
#
# ///
# imports
import os
from importlib import reload # noqa
import ibis
import IPython
from rich import console
# Ibis configuration
ibis.options.interactive = True
ibis.options.repr.interactive.max_rows = 40
ibis.options.repr.interactive.max_columns = None
# rich configuration
console = console.Console()
print = console.print
# path configuration
lakedir = os.getenv("LAKE", os.path.join(os.path.expanduser("~"), "lake"))
metadata_db = os.path.join(lakedir, "metadata.sqlite")
data_dir = os.path.join(lakedir, "data")
os.makedirs(data_dir, exist_ok=True)
# print banner
banner = """
▓█████▄ ▓█████ ██▒ █▓
▒██▀ ██▌▓█ ▀▓██░ █▒
░██ █▌▒███ ▓██ █▒░
░▓█▄ ▌▒▓█ ▄ ▒██ █░░
░▒████▓ ░▒████▒ ▒▀█░
▒▒▓ ▒ ░░ ▒░ ░ ░ ▐░
░ ▒ ▒ ░ ░ ░ ░ ░░
░ ░ ░ ░ ░░
░ ░ ░ ░
░ ░
""".strip()
console.print(banner, style="bold purple")
# create Ibis connections
metacon = ibis.sqlite.connect(metadata_db)
con = ibis.duckdb.connect()
init_sql = f"""
install ducklake;
install sqlite;
create secret (
type ducklake,
metadata_path 'sqlite:{metadata_db}',
data_path '{data_dir}'
);
attach 'sqlite:{metadata_db}' as metadata;
attach 'ducklake:' as data;
use data;
""".strip()
con.raw_sql(init_sql)
ibis.set_backend(con)
# create IPython shell
IPython.embed(
banner1="",
banner2="",
display_banner=False,
exit_msg="",
colors="linux",
theming="monokai",
)