mirror of
https://github.com/OHV-IT/collabrix.git
synced 2025-12-15 16:48:36 +01:00
- Complete chat application similar to Microsoft Teams - Code snippet library with syntax highlighting - Real-time messaging with WebSockets - File upload with Office integration - Department-based permissions - Dark/Light theme support - Production deployment with SSL/Reverse Proxy - Docker containerization - PostgreSQL database with SQLModel ORM
45 lines
922 B
Python
45 lines
922 B
Python
from sqlmodel import SQLModel, create_engine, Session
|
|
from app.config import get_settings
|
|
import os
|
|
|
|
settings = get_settings()
|
|
|
|
# Create engine
|
|
engine = create_engine(
|
|
settings.database_url,
|
|
echo=True,
|
|
pool_pre_ping=True
|
|
)
|
|
|
|
# Test engine
|
|
test_engine = None
|
|
|
|
|
|
def get_test_engine():
|
|
global test_engine
|
|
if test_engine is None:
|
|
test_engine = create_engine(
|
|
settings.test_database_url,
|
|
echo=True,
|
|
pool_pre_ping=True
|
|
)
|
|
return test_engine
|
|
|
|
|
|
def create_db_and_tables():
|
|
"""Create all database tables"""
|
|
SQLModel.metadata.create_all(engine)
|
|
|
|
|
|
def get_session():
|
|
"""Dependency for getting database session"""
|
|
with Session(engine) as session:
|
|
yield session
|
|
|
|
|
|
def get_test_session():
|
|
"""Dependency for getting test database session"""
|
|
test_eng = get_test_engine()
|
|
with Session(test_eng) as session:
|
|
yield session
|