Point type in sqlalchemy?

I found this regarding the type of Point in Postgres: http://www.postgresql.org/docs/current/interactive/datatype-geometric.html

Is there a version of SQLAlchemy?

I save the values ​​this way: (40.721959482, -73.878993913)

+4
source share
3 answers

I found this to be a small modification of Mohammad's answer.

Yes I need to add a point column through geo / sqlalchemy

from sqlalchemy import Column
from geoalchemy2 import Geometry
# and import others

class Shop(db.Model):
    # other fields
    coordinates = Column(Geometry('POINT'))

PostGIS/Gres PGloader, csv, : "(40.721959482, -73.878993913)" vim ( ) , PostGIS, csv point(40.721959482 -73.878993913), () location geometry(point).

0

geoalchemy2, sqlalchemy -sqlalchemy.

from sqlalchemy import Column
from geoalchemy2 import Geometry
# and import others

class Shop(db.Model):
    # other fields
    coordinates = Column(Geometry('POINT'))
0

UserDefinedType, .

, , , UserDefinedType

Please note that the answer of Mohammad Amin is valid only if your point is intended for a geographical point (latitude and longitude restrictions). It does not apply if you want to represent any point on the plane. In addition, in this case, you will need to install the PostGIS extension, which I recommend if you work with geography points, as it provides many utlities and additional functions.

0
source

All Articles