Skip to content

Answered: Simplest unpaginated page equivalent? #666

Answered by uriyyo
gitpushdashf asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @gitpushdashf,

I hope the example below will help you:

from typing import Any, Generic, List, Optional, TypeVar

from fastapi import FastAPI
from pydantic import BaseModel
from pydantic.generics import GenericModel
from sqlalchemy import select
from sqlmodel import Field, Session, SQLModel, create_engine

engine = create_engine("sqlite:///database.db")


class User(SQLModel, table=True):
    id: Optional[int] = Field(default=None, primary_key=True)
    name: str
    email: str


SQLModel.metadata.drop_all(engine)
SQLModel.metadata.create_all(engine)

app = FastAPI()


@app.on_event("startup")
async def on_startup() -> None:
    with Session(engine) as session:
        session.add(
    …

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@gitpushdashf
Comment options

@uriyyo
Comment options

@uriyyo
Comment options

@gitpushdashf
Comment options

@uriyyo
Comment options

Answer selected by uriyyo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants