Re: [sqlalchemy] Postgres custom composite types

2013-03-27 Thread Tobias Bieniek
GeoAlchemy is for SQLALchemy =0.7.x GeoAlchemy2 if for SQLALchemy =0.8 Kamil is mostly right. GeoAlchemy2 v0.1 is published on PyPI now, and GeoAlchemy(1) is also still available. The latter is still compatible with SQLAlchemy 0.8 though, but GeoAlchemy2 has a much easier code base and

[sqlalchemy] complex many to many relationship

2013-03-27 Thread Kevin S
Setup: I have been learning SQL Alchemy to build a prototype (proof of concept) Flask app for our internal website. We want to replace our current site, which is made entirely of slow python CGIs and raw SQL. Our database (Postgres) is fairly large, but has some unusual table relationships, and

Re: [sqlalchemy] complex many to many relationship

2013-03-27 Thread Simon King
On Wed, Mar 27, 2013 at 4:13 PM, Kevin S kevinrst...@gmail.com wrote: Setup: I have been learning SQL Alchemy to build a prototype (proof of concept) Flask app for our internal website. We want to replace our current site, which is made entirely of slow python CGIs and raw SQL. Our database

[sqlalchemy] Automatic created and modified timestamp columns (best practice?!)

2013-03-27 Thread Moritz Schlarb
Hi there everyone, I am kind of looking for a best practice on how to implement automatically setting and updating columns for created and modified timestamps in SQLAlchemy, preferrably database-agnostic. First of all, is DateTime the appropriate column type or should it be timestamp instead?

Re: [sqlalchemy] complex many to many relationship

2013-03-27 Thread Kevin S
Thanks. I have it working for the Marker to Reference_Assoc relationship: Marker.referenceAssocs = relationship(ReferenceAssoc, primaryjoin=and_(ReferenceAssoc._mgitype_key==2, ReferenceAssoc._object_key==Marker._marker_key), foreign_keys=[Marker._marker_key],

Re: [sqlalchemy] complex many to many relationship

2013-03-27 Thread Kevin S
Also, is it appropriate to define a backref here? It returns wrong data. When I get a ReferenceAssoc object and get its marker, it generates a query with a clause like: reference_assoc._mgitype_key = @_mgitype_key_1 AND @param_1 = marker._marker_key and these params :

Re: [sqlalchemy] complex many to many relationship

2013-03-27 Thread Kevin S
Ok, I'm sorry to be confusing. But this backref thing, it isn't returning random results, but the join condition is all wrong. It is taking a ReferenceAssoc object with type_key = 11 and object_key=215, and making the where clause I showed. So I get back a marker with marker_key 215, but really

Re: [sqlalchemy] Automatic created and modified timestamp columns (best practice?!)

2013-03-27 Thread Michael Bayer
On Mar 27, 2013, at 1:02 PM, Moritz Schlarb mosch...@metalabs.de wrote: Hi there everyone, I am kind of looking for a best practice on how to implement automatically setting and updating columns for created and modified timestamps in SQLAlchemy, preferrably database-agnostic. First of

[sqlalchemy] Re: Automatic created and modified timestamp columns (best practice?!)

2013-03-27 Thread Jonathan Vanasco
FWIW, I've found this sort of stuff to be better done with CURRENT_TIMESTAMP than NOW() , or doing a NOT NULL constraint with no-default and passing in a time from the application. On databases that support it, CURRENT_TIMESTAMP is locked to the transaction and/or statement while NOW() is