42 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
import asyncio
 | 
						|
import datetime
 | 
						|
 | 
						|
from sqlalchemy import select, func
 | 
						|
from sqlalchemy.ext.asyncio import AsyncSession
 | 
						|
from sqlalchemy.orm import joinedload
 | 
						|
 | 
						|
import models
 | 
						|
from backend.session import session_maker
 | 
						|
from models import User, PaymentRecord
 | 
						|
 | 
						|
 | 
						|
async def main():
 | 
						|
    session: AsyncSession = session_maker()
 | 
						|
    try:
 | 
						|
        deal_id = 133
 | 
						|
        source_product_id = 253
 | 
						|
        source_services_stmt = (
 | 
						|
            select(
 | 
						|
                models.DealProductService
 | 
						|
            )
 | 
						|
            .where(
 | 
						|
                models.DealProductService.product_id == source_product_id,
 | 
						|
                models.DealProductService.deal_id == deal_id,
 | 
						|
            )
 | 
						|
        )
 | 
						|
        result = (await session.scalars(source_services_stmt)).all()
 | 
						|
        services = [d.service for d in result]
 | 
						|
        for service in services:
 | 
						|
            print(
 | 
						|
                service.price_ranges
 | 
						|
 | 
						|
            )
 | 
						|
    except Exception as e:
 | 
						|
        print(e)
 | 
						|
    await session.close()
 | 
						|
 | 
						|
 | 
						|
if __name__ == '__main__':
 | 
						|
    loop = asyncio.get_event_loop()
 | 
						|
    loop.run_until_complete(main())
 |