Gino: Does it have postgis support?

Created on 12 Jan 2020  路  3Comments  路  Source: python-gino/gino

I want to build an async GIS application, is postgis or geospatial supported?

question

Most helpful comment

I'm using gino together with geoalchemy and it has been working OK so far.

I've only had the need to store geometries in my DB yet, so I'm not calling any postgis function directly. I don't see why that would fail either.

Here is a sample model:

import geoalchemy2
from gino import Gino
from sqlalchemy.dialects.postgresql import UUID

db = Gino()

class MyModel(db.Model):
    __tablename__ = "mymodels"

    id = db.Column(UUID, primary_key=True)
    name = db.Column(db.String(200), nullable=False, unique=True)
    projection = db.Column(db.String(200), nullable=False)
    bbox = db.Column(geoalchemy2.Geometry("Polygon"), nullable=True)

All 3 comments

I'm using gino together with geoalchemy and it has been working OK so far.

I've only had the need to store geometries in my DB yet, so I'm not calling any postgis function directly. I don't see why that would fail either.

Here is a sample model:

import geoalchemy2
from gino import Gino
from sqlalchemy.dialects.postgresql import UUID

db = Gino()

class MyModel(db.Model):
    __tablename__ = "mymodels"

    id = db.Column(UUID, primary_key=True)
    name = db.Column(db.String(200), nullable=False, unique=True)
    projection = db.Column(db.String(200), nullable=False)
    bbox = db.Column(geoalchemy2.Geometry("Polygon"), nullable=True)

Closing due to inactivity. Please feel free to reopen.

Does this work with postgis version 3?

db.gino.create_all() created the tables but skipped the column geom_point = db.Column(Geometry('POINT'), nullable=True).

I tried again, after dropping and re-creating the database.
Here is the stacktrace:

[2020-06-02 01:51:26 +0530] [111467] [INFO] Goin' Fast @ http://0.0.0.0:4500
Executing <Task pending name='Task-1' coro=<init_db() running at app.py:16> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f374d006160>()] created at /usr/lib/python3.8/asyncio/tasks.py:466> cb=[run_until_complete.<locals>.<lambda>()] created at /home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/sanic/server.py:648> took 0.272 seconds
[2020-06-02 01:51:27 +0530] [111471] [ERROR] Experienced exception while trying to serve
Traceback (most recent call last):
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/sanic/app.py", line 1170, in run
    serve(**server_settings)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/sanic/server.py", line 832, in serve
    trigger_events(before_start, loop)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/sanic/server.py", line 648, in trigger_events
    loop.run_until_complete(result)
  File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
  File "app.py", line 17, in init_db
    await db.gino.create_all()
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 347, in create_all
    await self.create(bind=bind, tables=tables, checkfirst=checkfirst)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 334, in create
    await getattr(bind, "_run_visitor")(
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/engine.py", line 859, in _run_visitor
    await getattr(conn, "_run_visitor")(*args, **kwargs)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/engine.py", line 530, in _run_visitor
    await visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 30, in traverse_single
    return await meth(obj, **kw)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 91, in visit_metadata
    await self.traverse_single(
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 30, in traverse_single
    return await meth(obj, **kw)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 119, in visit_table
    await _Async(table.dispatch.before_create)(
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 416, in call
    await _call_portable_instancemethod(fn, args, kw)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 402, in _call_portable_instancemethod
    m = getattr(fn.target, fn.name + "_async", None)
AttributeError: 'function' object has no attribute 'target'
Traceback (most recent call last):
  File "app.py", line 27, in <module>
    app.run(host='0.0.0.0', port=4500, debug=True)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/sanic/app.py", line 1170, in run
    serve(**server_settings)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/sanic/server.py", line 832, in serve
    trigger_events(before_start, loop)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/sanic/server.py", line 648, in trigger_events
    loop.run_until_complete(result)
  File "uvloop/loop.pyx", line 1456, in uvloop.loop.Loop.run_until_complete
  File "app.py", line 17, in init_db
    await db.gino.create_all()
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 347, in create_all
    await self.create(bind=bind, tables=tables, checkfirst=checkfirst)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 334, in create
    await getattr(bind, "_run_visitor")(
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/engine.py", line 859, in _run_visitor
    await getattr(conn, "_run_visitor")(*args, **kwargs)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/engine.py", line 530, in _run_visitor
    await visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 30, in traverse_single
    return await meth(obj, **kw)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 91, in visit_metadata
    await self.traverse_single(
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 30, in traverse_single
    return await meth(obj, **kw)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 119, in visit_table
    await _Async(table.dispatch.before_create)(
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 416, in call
    await _call_portable_instancemethod(fn, args, kw)
  File "/home/disciple/Documents/Code/MyProject-All/MyProject-Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 402, in _call_portable_instancemethod
    m = getattr(fn.target, fn.name + "_async", None)
AttributeError: 'function' object has no attribute 'target'
sys:1: RuntimeWarning: coroutine 'Loop.create_server' was never awaited
Was this page helpful?
0 / 5 - 0 ratings

Related issues

AmatanHead picture AmatanHead  路  5Comments

gizzatov picture gizzatov  路  3Comments

Pehat picture Pehat  路  3Comments

quantum13 picture quantum13  路  6Comments

paulin-mipt picture paulin-mipt  路  4Comments