mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Авторизация починка 2
This commit is contained in:
@@ -7,12 +7,14 @@ from pydantic import Field
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Bot configuration settings"""
|
||||
bot_token: str = Field(..., env="TELEGRAM_BOT_TOKEN")
|
||||
chat_id: str = Field(..., env="TELEGRAM_CHAT_ID")
|
||||
bot_token: str = Field(..., alias="TELEGRAM_BOT_TOKEN")
|
||||
chat_id: str = Field(..., alias="TELEGRAM_CHAT_ID")
|
||||
database_url: str = Field(..., alias="DATABASE_URL")
|
||||
|
||||
class Config:
|
||||
env_file = ".env"
|
||||
env_file_encoding = "utf-8"
|
||||
case_sensitive = True
|
||||
|
||||
# Create settings instance
|
||||
settings = Settings()
|
||||
|
@@ -1,12 +1,11 @@
|
||||
"""Database connection module"""
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
import os
|
||||
|
||||
DATABASE_URL = os.getenv("DATABASE_URL", "postgresql://support_user:support_password@localhost:5432/support_db")
|
||||
from .bot.config import settings
|
||||
|
||||
engine = create_engine(
|
||||
DATABASE_URL,
|
||||
settings.database_url,
|
||||
pool_size=5,
|
||||
max_overflow=10,
|
||||
pool_timeout=30,
|
||||
@@ -17,6 +16,7 @@ SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
Base = declarative_base()
|
||||
|
||||
def get_db():
|
||||
"""Get database session"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
|
Reference in New Issue
Block a user