Is it possible to use PostGIS geometry types in models created in SQLModel? If yes, how can it be done?
Yes it is.
Just take advantage of the sqlalchemy
package that makes the work underneath SQLModel
and the the GeoAlchemy2
package which is compatible with sqlalchemy
and has already defined geometry types.
So,
from geoalchemy2 import Geometry
from sqlmodel import SQLModel, Field, Column
class Record(SQLModel, table=True):
point: Any = Field(sa_column=Column(Geometry('POINT'))) # Here POINT is used but could be other geometries as well