mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Создания скрипта, юзера3
This commit is contained in:
3
backend/scripts.py/__init__.py
Normal file
3
backend/scripts.py/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
"""Scripts package initialization"""
|
||||||
|
|
||||||
|
from .create_test_user import create_test_employee
|
@@ -1,5 +1,10 @@
|
|||||||
"""Script to create a test user in the database"""
|
"""Script to create a test user in the database"""
|
||||||
from sqlalchemy.orm import Session
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
# Add the parent directory to sys.path
|
||||||
|
sys.path.append(str(Path(__file__).resolve().parents[1]))
|
||||||
|
|
||||||
from app.database import SessionLocal
|
from app.database import SessionLocal
|
||||||
from app.crud import employees
|
from app.crud import employees
|
||||||
from app.models.employee import EmployeeCreate
|
from app.models.employee import EmployeeCreate
|
||||||
@@ -28,6 +33,7 @@ def create_test_employee():
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Error creating test employee: {e}")
|
print(f"Error creating test employee: {e}")
|
||||||
|
raise e
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
Reference in New Issue
Block a user