The backend component to interface with the smart contract.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

27 行
642 B

  1. from sqlalchemy.ext.declarative import declarative_base
  2. from sqlalchemy.ext.asyncio import AsyncEngine, create_async_engine
  3. from sqlalchemy.orm import sessionmaker
  4. from sqlalchemy.ext.asyncio import AsyncSession
  5. from app.core.config import settings
  6. # Create async engine
  7. engine = create_async_engine(
  8. settings.DATABASE_URL,
  9. pool_pre_ping=True,
  10. pool_size=10,
  11. max_overflow=20
  12. )
  13. # Create a custom session class
  14. AsyncSessionLocal = sessionmaker(
  15. engine,
  16. class_=AsyncSession,
  17. expire_on_commit=False,
  18. autocommit=False,
  19. autoflush=False
  20. )
  21. # Create a base class for declarative models
  22. Base = declarative_base()