Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this work with postgis version 3? #691

Closed
nikhilpatil02 opened this issue Jun 2, 2020 · 9 comments
Closed

Does this work with postgis version 3? #691

nikhilpatil02 opened this issue Jun 2, 2020 · 9 comments
Labels
bug Describes a bug in the system.

Comments

@nikhilpatil02
Copy link

nikhilpatil02 commented Jun 2, 2020

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/All/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/All/Sanic/venv/lib/python3.8/site-packages/sanic/app.py", line 1170, in run
    serve(**server_settings)
  File "/home/disciple/Documents/Code/All/Sanic/venv/lib/python3.8/site-packages/sanic/server.py", line 832, in serve
    trigger_events(before_start, loop)
  File "/home/disciple/Documents/Code/All/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/All/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/All/Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 334, in create
    await getattr(bind, "_run_visitor")(
  File "/home/disciple/Documents/Code/All/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/All/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/All/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/All/Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 91, in visit_metadata
    await self.traverse_single(
  File "/home/disciple/Documents/Code/All/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/All/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/All/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/All/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/All/Sanic/venv/lib/python3.8/site-packages/sanic/app.py", line 1170, in run
    serve(**server_settings)
  File "/home/disciple/Documents/Code/All/Sanic/venv/lib/python3.8/site-packages/sanic/server.py", line 832, in serve
    trigger_events(before_start, loop)
  File "/home/disciple/Documents/Code/All/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/All/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/All/Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 334, in create
    await getattr(bind, "_run_visitor")(
  File "/home/disciple/Documents/Code/All/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/All/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/All/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/All/Sanic/venv/lib/python3.8/site-packages/gino/schema.py", line 91, in visit_metadata
    await self.traverse_single(
  File "/home/disciple/Documents/Code/All/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/All/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/All/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/All/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

Originally posted by @diptangsu in #627 (comment)

@fantix
Copy link
Member

fantix commented Jun 5, 2020

This might be a bug in db.gino.create_all() - its compatibility is not as good as the query execution part of GINO. Before this is more carefully looked into, I'd suggest using Alembic for schema management.

@fantix fantix added the bug Describes a bug in the system. label Jun 5, 2020
@diptangsu
Copy link

Thank you for the quick response @fantix
Using alembic solved this problem while being a better alternative. It's easy to set up by following the docs and gets the job done.

@wwwjfy
Copy link
Member

wwwjfy commented Jun 20, 2020

Just submitted a commit to fix the error message, but the real issue is geoalchemy will execute statements after table creation using events in the synchronous way. code

I don't see any easy and clean way to fix this, sadly.

@diptangsu
Copy link

It anyway a better choice to use migrations with alembic. And it works properly with alembic and it also removes the necessity of using db.gino.create_all(). That's what I did to get around this problem.

@wwwjfy
Copy link
Member

wwwjfy commented Jun 21, 2020

Yep. To replace psycopg2 completely, we'll need to do that for everything in the system. Much effort.

If no objection, I think we can close this issue.

@diptangsu
Copy link

Sure. I think it'd be a good idea to mention this issue somewhere if possible. Maybe in the docs or somewhere appropriate.

@wwwjfy
Copy link
Member

wwwjfy commented Jun 21, 2020

It is mentioned that create_all is not ideal, in https://python-gino.org/docs/en/master/tutorials/tutorial.html

@diptangsu
Copy link

Oh! My bad. It's exactly what should be written.

@wwwjfy
Copy link
Member

wwwjfy commented Jun 28, 2020

Closing

@wwwjfy wwwjfy closed this as completed Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Describes a bug in the system.
Projects
None yet
Development

No branches or pull requests

4 participants