I am stuck into a problem with GINO. I can get a one row from my table called templates, so in the other route i want to get all rows from table. Here you can see my view for get one record from db ant it works perfect.
@router.get("/templates/{uid}")
async def get_template(uid: str):
temp = await Template.get_or_404(uid)
return temp.to_dict()
Next you can look at my view to add record to db and it also works fine:
@router.post("/templates")
async def add_template(template: TemplateModel):
rv = await Template.create(name=template.name, text=template.text)
return rv.to_dict()
So, the main cause in this view, it doesn't work:
@router.get("/templates/all")
async def get_all_templates():
temp = await Template.all()
return temp.to_dict()
Look down below for my Template model:
class Template(db.Model):
__tablename__ = "templates"
UUID = db.Column(
str(UUID(as_uuid=True)),
db.String,
primary_key=True,
default=str(uuid.uuid4()),
unique=True,
nullable=False,
)
name = db.Column("name", db.String, nullable=False)
text = db.Column("text", db.String, nullable=False)
created_at = db.Column("created_at", db.DateTime, nullable=False,
server_default=db.func.now())
And finally my db GINO engine:
from gino_starlette import Gino
from .. import config
db = Gino(
dsn=config.DB_DSN,
pool_min_size=config.DB_POOL_MIN_SIZE,
pool_max_size=config.DB_POOL_MAX_SIZE,
echo=config.DB_ECHO,
)
ERROR LOG:
2020-08-08 12:07:57,698 INFO gino.engine._SAEngine SELECT templates."UUID", templates.name, templates.text, templates.created_at
FROM templates
WHERE templates."UUID" = $1
2020-08-08 12:07:57,699 INFO gino.engine._SAEngine ('all',)
INFO: 172.23.0.1:40676 - "GET /templates/all HTTP/1.1" 404 Not Found
Please tell me what's wrong, i spent so much time to solve this problem. Feel free to answer, thanks.