Web2py con leaftlet e postgresql

16 views
Skip to first unread message

Gabriel Schubert

unread,
Dec 19, 2017, 9:22:17 PM12/19/17
to web2py-usuarios

Hello,


I'm trying to run this application (https://github.com/ilvalle/w2pgis) and I'm getting the following problem:


gabrielschubert@Gabriel-Notebook ~/Documents/web2py/web2py $ python web2py.py -a 123 -i 127.0.0.1 -p 8000 -S leaftlet -M
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2017
Version 2.16.1-stable+timestamp.2017.11.14.05.54.25
Database drivers available: sqlite3, psycopg2, pg8000, pymysql, imaplib
Traceback (most recent call last):
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "applications/leaftlet/models/db.py", line 6, in <module>
    Field('geometry', 'geometry()'),
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/base.py", line 586, in define_table
    table = self.lazy_define_table(tablename, *fields, **args)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/base.py", line 620, in lazy_define_table
    polymodel=polymodel)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/adapters/base.py", line 797, in create_table
    return self.migrator.create_table(*args, **kwargs)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/migrator.py", line 277, in create_table
    self.adapter.create_sequence_and_triggers(query, table)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/adapters/base.py", line 880, in create_sequence_and_triggers
    self.execute(query)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 67, in wrap
    return f(*args, **kwargs)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/adapters/base.py", line 412, in execute
    rv = self.cursor.execute(command, *args[1:], **kwargs)
ProgrammingError: relation "geostuff" already exists

First time I've tried to execute, I got the following error:

gabrielschubert@Gabriel-Notebook ~/Documents/web2py/web2py $ python web2py.py -a 123 -i 127.0.0.1 -p 8000 -S leaftlet -M
web2py Web Framework
Created by Massimo Di Pierro, Copyright 2007-2017
Version 2.16.1-stable+timestamp.2017.11.14.05.54.25
Database drivers available: sqlite3, psycopg2, pg8000, pymysql, imaplib
Traceback (most recent call last):
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "applications/leaftlet/models/db.py", line 6, in <module>
    Field('geometry', 'geometry()'),
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/base.py", line 586, in define_table
    table = self.lazy_define_table(tablename, *fields, **args)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/base.py", line 620, in lazy_define_table
    polymodel=polymodel)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/adapters/base.py", line 797, in create_table
    return self.migrator.create_table(*args, **kwargs)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/migrator.py", line 282, in create_table
    self.adapter.execute(query)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/adapters/__init__.py", line 67, in wrap
    return f(*args, **kwargs)
  File "/home/gabrielschubert/Documents/web2py/web2py/gluon/packages/dal/pydal/adapters/base.py", line 412, in execute
    rv = self.cursor.execute(command, *args[1:], **kwargs)
ProgrammingError: function addgeometrycolumn(unknown, unknown, unknown, integer, unknown, integer) does not exist
LINE 1: SELECT AddGeometryColumn ('', 'geostuff', 'geometry', 4326, ...
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.


I'm using the following code:


# -*- coding: utf-8 -*-
db = DAL('postgres://web2py:web2py@localhost:5432/leaflet', lazy_tables=False)

db.define_table('geostuff',
    Field('name', 'string'),
    Field('geometry', 'geometry()'),
)


n_rows = db(db.geostuff).count()
if not n_rows:
    db.geostuff.insert(name="My first geo point (London!)", geometry="POINT(-0.091109 51.512622)")
    db.geostuff.insert(name="My first linestring", geometry="LINESTRING (8.791595 45.660281, 11.343062 44.494932, 10.394590 43.722998)")


Could you help me please?


Ty.

Reply all
Reply to author
Forward
0 new messages