Hello,

I need to query, insert, update and delete from already existing
PostGIS tables.

After much trial and error, nothing worked. Then I came across this
message:
http://groups.google.com/group/sqlalchemy/msg/424d9aa10d30abaf

Following that, I've confirmed that the following works:

f = func.GeomFromText('POINT(-118.0 34.0)',4326)
ins = tbl_test.insert().values(id=97, location=f)
conn = engine.connect()
trans = conn.begin()
conn.execute(ins)
trans.commit()
conn.close()

which is nice, but I like to work with connectionless or implicit
execution (as described in SQLAlchemy 0.5.3 Documentation). So I
tried:

tbl_test.insert().execute(id=42, location=f)

but it doesn't work. The error returned was:

sqlalchemy.exc.ProgrammingError: (ProgrammingError) can't adapt
'INSERT INTO tbl_test (id, location) VALUES (%(id)s, %(location)
s)' {'id': 42, 'location': <sqlalchemy.sql.expression.Function at
0x830dd8c; GeomFromText>}

So I suspect this has to do with how slqalchemy understands my table
schema?

I currently am declaring the table as

tbl_test = Table('tbl_test', self.metadata, Column('event_id',
Integer), Column('location', Geometry(2, 4326), nullable=False))

where Geometry is copied and pasted from some post found using Google:

class Geometry(TypeEngine):
    """Base PostGIS Geometry column type"""

    name = 'GEOMETRY'

    def __init__(self, dimension, srid=-1):
        self.dimension = dimension
        self.srid = srid

    def bind_processor(self, dialect):
        def process(value):
            return value
        return process

    def result_processor(self, dialect): #not used yet
        def process(value):
                return value
        return process


Can anyone help? According to Michael Bayer in that old post, the
connectionless statement should work.

Thank you

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to