Сервис для хранения файлов аудио, индексации файлов, записи и выдачи результатов распознавания
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
1.3 KiB

#!/usr/bin/env python3
"""
Скрипт для инициализации базы данных
Создаёт все необходимые таблицы
"""
from apiApp.database import Base, engine
from sqlalchemy import inspect
def init_database():
"""Создаёт все таблицы в базе данных"""
print("🔧 Инициализация базы данных...")
# Проверяем существующие таблицы
inspector = inspect(engine)
existing_tables = inspector.get_table_names()
if existing_tables:
print(f"📋 Существующие таблицы: {', '.join(existing_tables)}")
# Создаём все таблицы
Base.metadata.create_all(bind=engine)
# Проверяем результат
inspector = inspect(engine)
all_tables = inspector.get_table_names()
print(f"✅ Создано таблиц: {len(all_tables)}")
for table in all_tables:
print(f" - {table}")
return all_tables
if __name__ == "__main__":
try:
tables = init_database()
print(f"\n🎉 База данных готова! Создано таблиц: {len(tables)}")
except Exception as e:
print(f"\n❌ Ошибка при создании таблиц: {e}")
exit(1)