Spaces:
Sleeping
Sleeping
File size: 691 Bytes
e84abc1 2a27c15 e84abc1 2a27c15 e84abc1 2a27c15 ddf7165 |
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 |
import duckdb
import os
import subprocess
import streamlit as st
DBT_DIR = os.path.join(os.path.dirname(__file__), "dbt_yfdash")
DUCKDB_PATH = os.path.join(DBT_DIR, "dev.duckdb")
def get_db_conn():
return duckdb.connect(DUCKDB_PATH)
def run_dbt_build():
process = subprocess.Popen(
args=["dbt", "build"],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
cwd=DBT_DIR,
)
stdout, _ = process.communicate()
st.text("\n".join(stdout.decode().split("\n")[1:][:-1]))
def get_current_tables(duckdb_conn=get_db_conn()) -> list[str]:
current_tables_df = duckdb_conn.sql("SHOW TABLES").df()
return current_tables_df["name"].tolist()
|