First Check
Commit to Help
Example Code
from typing import Any, List
from fastapi import APIRouter, Depends
from sqlmodel import Session, select, text, SQLModel
from pydantic import BaseModel
from app.api.deps import get_session_legacy
router = APIRouter(prefix="/")
class Test(BaseModel):
hello: str
@router.get("/data", response_model=List[Test])
async def get_data(
db: Session = Depends(get_session_legacy)
):
sql = text(
"""
SELECT 'hi' AS "hello"
"""
)
result = db.exec(sql).all()
for res in result:
logger.info(f"response: {res}")
return result
Description
When using db.exec(select(Hero)) you can use auto-suggestion in vscode to see the methods that belong to exec().
However when using db.exec(text("SELECT * FROM hero")) then there are no suggestions following the exec().
Wanted Solution
I want to see the suggestions: db.exec(text()).[one(), all(), scalars(), etc...]
Wanted Code
from typing import Any, List
from fastapi import APIRouter, Depends
from sqlmodel import Session, select, text, SQLModel
from pydantic import BaseModel
from app.api.deps import get_session_legacy
router = APIRouter(prefix="/")
class Test(BaseModel):
hello: str
@router.get("/data", response_model=List[Test])
async def get_data(
db: Session = Depends(get_session_legacy)
):
sql = text(
"""
SELECT 'hi' AS "hello"
"""
)
result = db.exec(sql).[all(), one(), scallars()... etc]
for res in result:
logger.info(f"response: {res}")
return result
Alternatives
No response
Operating System
Linux
Operating System Details
wsl2 on windows, vscode
SQLModel Version
0.0.6
Python Version
3.10
Additional Context
No response
First Check
Commit to Help
Example Code
Description
When using
db.exec(select(Hero))you can use auto-suggestion in vscode to see the methods that belong to exec().However when using
db.exec(text("SELECT * FROM hero"))then there are no suggestions following the exec().Wanted Solution
I want to see the suggestions:
db.exec(text()).[one(), all(), scalars(), etc...]Wanted Code
Alternatives
No response
Operating System
Linux
Operating System Details
wsl2 on windows, vscode
SQLModel Version
0.0.6
Python Version
3.10
Additional Context
No response