There's a lot of documentation on this, not sure how you're not finding it, unless you're not using 0.8 (which is required):
1. documentation for SQL bind/result column processing: http://docs.sqlalchemy.org/en/latest/core/types.html#types-sql-value-processing 2. a full example using PostGIS: http://docs.sqlalchemy.org/en/latest/orm/examples.html#examples-postgis (this example has an ORM-centric version in 0.7 too, which is no longer current..) 3. geoalchemy is pretty relevant since you can read its source (current tip uses new techniques) to see how they are doing it. On Nov 18, 2012, at 8:47 AM, Vlad K. wrote: > > Hello list, > > > I can't find an example for a user defined type that has to produce custom > SQL. What I want is to implement a PostGIS geometry column and it basically > has to do two things: > > > 1. Implement own SQL for insert/update, to produce for example: > > INSERT INTO .... (..., xyzzy, ....) VALUES (..., transform(PointFromText( > %s ), 4269), 32661) , ....) .... > > UPDATE .... SET xyzzy=transform(PointFromText( %s ), 4269), 32661) ... > > > 2. Internally carry a tuple X that will be bound as string "POINT({0} > {1})".format(x[0], x[1]) > > 3. Parse PostgreSQL array result back into tuple X > > > > I've managed to produce #2 and #3 with a UserDefinedType, but I don't know > how to tell it to produce custom SQL, aside to bind_processor, for #1. I'm > also using get_col_spec for the UserDefinedType for DDL. > > > BTW, GeoAlchemy is beside the point here. I want to learn how to produce > custom types like this. > > > Thanks, > > -- > > > .oO V Oo. > > > Work Hard, > Increase Production, > Prevent Accidents, > and > Be Happy! ;) > > -- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sqlalchemy?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
