feat: warehouse places accounting
This commit is contained in:
		
							
								
								
									
										21
									
								
								backend/wms_session.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								backend/wms_session.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,21 @@
 | 
			
		||||
from typing import AsyncGenerator
 | 
			
		||||
 | 
			
		||||
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
 | 
			
		||||
from sqlalchemy.orm import sessionmaker
 | 
			
		||||
 | 
			
		||||
from .config import WMS_PG_DATABASE, WMS_PG_HOST, WMS_PG_PASSWORD, WMS_PG_LOGIN
 | 
			
		||||
 | 
			
		||||
DATABASE_URL = f'postgresql+asyncpg://{WMS_PG_LOGIN}:{WMS_PG_PASSWORD}@{WMS_PG_HOST}/{WMS_PG_DATABASE}'
 | 
			
		||||
engine = create_async_engine(DATABASE_URL)
 | 
			
		||||
wms_session_maker = sessionmaker(
 | 
			
		||||
    engine,
 | 
			
		||||
    class_=AsyncSession,
 | 
			
		||||
    expire_on_commit=False,
 | 
			
		||||
    autocommit=False,
 | 
			
		||||
    autoflush=False,
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
async def get_wms_session() -> AsyncGenerator[AsyncSession, None]:
 | 
			
		||||
    async with wms_session_maker() as session:
 | 
			
		||||
        yield session
 | 
			
		||||
		Reference in New Issue
	
	Block a user