Spaces:
Build error
Build error
File size: 610 Bytes
7aebe32 037ba4c 7aebe32 716c2a2 037ba4c 7aebe32 037ba4c 7aebe32 037ba4c 7aebe32 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from sqlalchemy import create_engine, MetaData, inspect
# Initialize database engine (Persistent SQLite)
engine = create_engine("sqlite:///database.db")
metadata_obj = MetaData()
# Function to check existing tables
def get_existing_tables():
inspector = inspect(engine)
return inspector.get_table_names()
# Function to initialize database if empty
def initialize_database():
tables = get_existing_tables()
if not tables:
print("No tables found in the database. Please upload an SQL file.")
else:
print(f"Database initialized with tables: {tables}")
initialize_database() |