syn-genie / schema_parser.py
vivekprojects-GIT
Add distribution comparison charts for real vs. synthetic data
0518c53
Raw
History Blame Contribute Delete
516 Bytes
# schema_parser.py
import pandas as pd
from sdv.metadata import SingleTableMetadata
from db_connector import fetch_table_data
def infer_schema_from_csv(file_path):
df = pd.read_csv(file_path)
metadata = SingleTableMetadata()
metadata.detect_from_dataframe(df)
return df, metadata
def infer_schema_from_db(db_url, db_password, table_name):
df = fetch_table_data(db_url, db_password, table_name)
metadata = SingleTableMetadata()
metadata.detect_from_dataframe(df)
return df, metadata