Spaces:
Running
Running
import pandas as pd | |
from sqlalchemy import create_engine, inspect | |
SUPPORTED_ENGINES = ["SQLite", "PostgreSQL", "MySQL", "MSSQL", "Oracle"] | |
def list_tables(conn_str): | |
engine = create_engine(conn_str) | |
inspector = inspect(engine) | |
return inspector.get_table_names() | |
def fetch_data_from_db(conn_str, table): | |
engine = create_engine(conn_str) | |
df = pd.read_sql_table(table, engine) | |
csv_path = f"data/{table}_extracted.csv" | |
df.to_csv(csv_path, index=False) | |
return csv_path | |