On Sep 21, 2006, at 2:16 AM, Wyatt Baldwin wrote: > I am attempting to use SQLAlchemy with PostGIS (spatial extensions for > Postgres). I'm wondering if anyone out there has any experience with > this. > > > I was considering looking into the SQLAlchemy types and seeing if I > could hack together a geometry type. One thing that looks tricky is > that, as far as I can tell, the geometry column must be added after > the table is created. The PostGIS docs say to do this: > > CREATE TABLE "raw"."portlandor" ( > [normal columns here] > ) > > and then in a separate step: > > SELECT AddGeometryColumn > ('raw','portlandor','the_geom','2913','MULTILINESTRING',2); > > > A google search for postgis + sqlalchemy[1] doesn't turn up anything > useful that I can see. The 2nd item there is a post on my own site, > which just happens to mention both of postgis and sqlalchemy. > > Any ideas?
It is possible to use SA without using the DDL management features. I usually write a separate DDL script that creates all my tables, indexes, constraints, triggers, etc. and then simply run SA against the database created by that script. It's usually not that much work to write separate DDL and keep it in sync with my SA tables and mappers. However, as I was writing that I realized that what you need to do should be possible with SA right now. Try this (untested code): portlandor_table = Table("portlandor", metadata, <normal column definitions here> ) def create_all(metadata=metadata): metadata.create_all() engine = metadata.engine # add geometry columns after tables are created engine.func.AddGeometryColumn('raw', 'portlandor', 'the_geom', '2913', 'MULTILINESTRING', 2).execute() portlandor_table.append_column(Column("the_geom", Geometry)) Then just use the custom create_all() function to create your tables. Of course you will need to create the "Geometry" column type as well since it is not provided by SA. ~ Daniel ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Sqlalchemy-users mailing list Sqlalchemy-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users