febus982/bootstrap-python-fastapi

View on GitHub
src/bootstrap/storage/SQLAlchemy/default_bind_tables.py

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
from sqlalchemy import Column, Integer, String, Table
from sqlalchemy.orm import registry

from domains.books._models import BookModel


def init_tables(registry_mapper: registry):
    books = Table(
        "books",
        registry_mapper.metadata,
        Column("book_id", Integer, primary_key=True),
        Column("title", String(50)),
        Column("author_name", String(50)),
    )
    registry_mapper.map_imperatively(BookModel, books)