79336885

Date: 2025-01-07 17:46:53
Score: 0.5
Natty:
Report link

The error you're getting suggests that the ST_GeomFromEWKT function is not available. This function is part of PostGIS, so it seems that either PostGIS is not properly installed or not enabled in your database.

  1. Ensure PostGIS is properly installed and enabled in your database. You can check this by running the SQL command:

    SELECT PostGIS_version();

If this returns a version number, PostGIS is installed and enabled.

  1. Modify your SQLAlchemy class to use Geography instead of Geometry in python:

    from geoalchemy2 import Geography

    class Prueba(Base): # ... other columns ... punto = Column(Geography(geometry_type='POINT', srid=4326))

  2. When inserting data, use the func.ST_GeogFromText function:

    from sqlalchemy import func

    prueba = Prueba( name="Prueba_2", age=5, created_at=datetime.now(), punto=func.ST_GeogFromText('POINT(-1.0 1.0)', 4326) )

    with Session() as session: session.add(prueba) session.commit()

This approach should work with your PostGIS-enabled table in Supabase. It uses the ST_GeogFromText function to convert the WKT string to a geography object directly in the database.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: italiano