33# dependencies = [
44# "duckdb==1.1.1",
55# "marimo",
6+ # "numpy==2.2.6",
7+ # "pandas==2.2.3",
68# "polars==1.18.0",
79# "pyarrow==18.1.0",
10+ # "sqlglot==26.19.0",
811# ]
912# ///
1013
1114import marimo
1215
13- __generated_with = "0.9.1 "
16+ __generated_with = "0.13.11 "
1417app = marimo .App (width = "full" )
1518
1619
1720@app .cell
18- def __ ():
21+ def _ ():
1922 import os
2023
2124 import duckdb
@@ -24,19 +27,19 @@ def __():
2427
2528
2629@app .cell (hide_code = True )
27- def __ (mo ):
30+ def _ (mo ):
2831 mo .md (
2932 r"""
30- # Database explorer
33+ # Database explorer
3134
32- This notebook lets you explore the contents of a database. Start by providing a database URL.
33- """
35+ This notebook lets you explore the contents of a database. Start by providing a database URL.
36+ """
3437 )
3538 return
3639
3740
3841@app .cell
39- def __ (mo , os ):
42+ def _ (mo , os ):
4043 database_url = mo .ui .text (
4144 label = "Database URL" ,
4245 full_width = True ,
@@ -47,9 +50,7 @@ def __(mo, os):
4750
4851
4952@app .cell
50- def __ (database_url ):
51- import duckdb
52-
53+ def _ (database_url , duckdb ):
5354 if database_url .value :
5455 duckdb .sql (
5556 f"""
@@ -60,23 +61,23 @@ def __(database_url):
6061 ATTACH DATABASE '{ database_url .value } ' AS my_db (TYPE postgres, READ_ONLY);
6162 """
6263 )
63- return duckdb , my_db
64+ return ( my_db ,)
6465
6566
6667@app .cell
67- def __ (duckdb ):
68+ def _ (duckdb ):
6869 duckdb .sql ("SHOW DATABASES" ).show ()
6970 return
7071
7172
7273@app .cell (hide_code = True )
73- def __ (mo ):
74+ def _ (mo ):
7475 mo .md (r"""## Tables""" )
7576 return
7677
7778
7879@app .cell
79- def __ (mo ):
80+ def _ (mo ):
8081 _df = mo .sql (
8182 f"""
8283 SHOW ALL TABLES;
@@ -86,13 +87,13 @@ def __(mo):
8687
8788
8889@app .cell (hide_code = True )
89- def __ (mo ):
90+ def _ (mo ):
9091 mo .md (r"""## Other meta table functions""" )
9192 return
9293
9394
9495@app .cell
95- def __ ():
96+ def _ ():
9697 FUNCTIONS = [
9798 "duckdb_columns()" , # columns
9899 "duckdb_constraints()" , # constraints
@@ -115,7 +116,7 @@ def __():
115116
116117
117118@app .cell
118- def __ (FUNCTIONS , mo ):
119+ def _ (FUNCTIONS , mo ):
119120 function = mo .ui .dropdown (
120121 label = "Dropdown" ,
121122 options = FUNCTIONS ,
@@ -126,7 +127,7 @@ def __(FUNCTIONS, mo):
126127
127128
128129@app .cell
129- def __ ( _ , function , mo ):
130+ def _ ( function , mo ):
130131 _df = mo .sql (
131132 f"""
132133 SELECT * FROM { function .value } WHERE database_name == 'my_db'
@@ -136,25 +137,25 @@ def __(_, function, mo):
136137
137138
138139@app .cell (hide_code = True )
139- def __ (mo ):
140+ def _ (mo ):
140141 mo .md (r"""## Interact with your tables""" )
141142 return
142143
143144
144145@app .cell
145- def __ (duckdb , duckdb_tables , mo ):
146+ def _ (duckdb , mo ):
146147 tables = duckdb .execute (
147148 """
148149 SELECT table_name FROM duckdb_tables() WHERE internal = False;
149150 """
150151 ).df ()
151152 table_names = list (tables ["table_name" ])
152153 mo .accordion ({f"Found { len (table_names )} tables" : table_names })
153- return table_names , tables
154+ return ( table_names ,)
154155
155156
156157@app .cell
157- def __ (mo , table_names ):
158+ def _ (mo , table_names ):
158159 mo .stop (not table_names )
159160 table_select = mo .ui .dropdown (
160161 label = "Table" ,
@@ -173,14 +174,14 @@ def __(mo, table_names):
173174
174175
175176@app .cell
176- def __ (mo , table_select ):
177+ def _ (mo , table_select ):
177178 mo .stop (not table_select .value )
178179 table_select_value = table_select .value
179180 return (table_select_value ,)
180181
181182
182183@app .cell
183- def __ (limit , mo , table_select_value ):
184+ def _ (limit , mo , my_db , null , table_select_value ):
184185 selected_table = mo .sql (
185186 f"""
186187 select * from my_db.{ table_select_value } LIMIT { limit .value } ;
@@ -190,7 +191,7 @@ def __(limit, mo, table_select_value):
190191
191192
192193@app .cell
193- def __ (mo , selected_table ):
194+ def _ (mo , selected_table ):
194195 mo .ui .data_explorer (selected_table )
195196 return
196197
0 commit comments