Source code for codegen_database.utils.query
from typing import TYPE_CHECKING
from sqlalchemy.dialects import postgresql
if TYPE_CHECKING:
from sqlalchemy.sql.selectable import SelectBase
[docs]
def compile_query(query: SelectBase) -> str:
"""Compile a SQLAlchemy query to a PostgreSQL SQL string."""
return str(
query.compile(
dialect=postgresql.dialect(),
compile_kwargs={"literal_binds": True},
)
)