Skip to content

Commit a552058

Browse files
committed
Open both db with launch script
1 parent 7872087 commit a552058

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

data/exploration/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@ duckdb data/exploration/odis.duckdb -ui
4040
**Option 2 : Via le script Python** (depuis la racine du projet)
4141

4242
```bash
43-
# Ouvrir la base odis.duckdb (par défaut)
4443
uv run python data/utils/launch_ui.py
45-
46-
# Ou ouvrir la base dev.duckdb
47-
uv run python data/utils/launch_ui.py dev.duckdb
4844
```
4945

5046
Le script va démarrer le serveur DuckDB UI et ouvrir automatiquement votre navigateur. Appuyez sur `Ctrl+C` pour arrêter le serveur.

data/utils/launch_ui.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env python
22
"""Launch DuckDB UI for the database."""
3+
34
import sys
45
import webbrowser
56
from pathlib import Path
7+
68
import duckdb
79

810

@@ -11,23 +13,26 @@ def main():
1113
project_root = Path(__file__).parent.parent.parent
1214
exploration_dir = project_root / "data" / "exploration"
1315

16+
db_name = "dev.duckdb"
1417
# Default to odis.duckdb, or use command line argument
15-
db_name = sys.argv[1] if len(sys.argv) > 1 else "odis.duckdb"
18+
odis_db_name = sys.argv[1] if len(sys.argv) > 1 else "odis.duckdb"
1619
db_file = exploration_dir / db_name
20+
odis_db_file = exploration_dir / odis_db_name
1721

1822
# Check if database exists
19-
if not db_file.exists():
20-
print(f"❌ Database not found: {db_file}")
23+
if not odis_db_file.exists():
24+
print(f"❌ Database not found: {odis_db_file}")
2125
print(f"\nAvailable databases in {exploration_dir}:")
2226
for db in exploration_dir.glob("*.duckdb"):
2327
print(f" - {db.name}")
2428
sys.exit(1)
2529

26-
print(f"🦆 Launching DuckDB UI for {db_file}...")
30+
print(f"🦆 Launching DuckDB UI for {db_file} {odis_db_file}...")
2731

2832
# Connect to the database and start UI
2933
conn = duckdb.connect(str(db_file))
30-
result = duckdb.sql("CALL start_ui();").fetchone()
34+
conn.sql(f"ATTACH DATABASE '{odis_db_file}' AS odis;")
35+
result = conn.sql("CALL start_ui();").fetchone()
3136

3237
if result and result[0]:
3338
url = result[0]
@@ -39,6 +44,7 @@ def main():
3944
# Keep the connection alive
4045
try:
4146
import time
47+
4248
while True:
4349
time.sleep(1)
4450
except KeyboardInterrupt:

0 commit comments

Comments
 (0)