[sqlalchemy] Filtering by an attribute of a related class (abusing generative filters...)

2009-02-28 Thread Ben Zealley
Hi all, I've got a requirement that seems like it should be fairly straightforward, but my own attempts to work out the necessary code have just become more and more contrived, and still don't work :( so I'm hoping someone more familiar with SQLA's design can suggest a better approach!

[sqlalchemy] Inspecting DDL of a Table object, without executing the code

2009-02-28 Thread Alex Willmer
I suspect the answer to this is obvious, but it eludes me. I have defined some SQlAlchemy table classes, using declarative_base, to interact with some tables in an SQL Server database. I'm unsure that the types I've chosen are correct. I want to print the CREATE TABLE ddl, without executing it.

[sqlalchemy] foreignkey and relation synchronization

2009-02-28 Thread laurent
Hello, There's a behaviour in SA that is not clear to me: if we look at the example (User and Address) from the docs, we can change either the related object or the foreign key For example: ad = Address(email_address='j...@google.com') ad.user = jack OR ad.user_id = 1 What is the prefered

[sqlalchemy] Re: Connecting with Windows Auth?

2009-02-28 Thread Alex Willmer
On Feb 25, 4:16 pm, Adam Pletcher adam.pletc...@gmail.com wrote: Is it possible to connect to a server using Windows Authentication using sqlalchemy? Yes it is, the syntax is: 'mssql://hostname/database?trusted_connection=yes' If you're connecting to a SQLEXPRESS instance, this becomes:

[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-02-28 Thread eLuke
On Feb 25, 12:17 pm, Roger Demetrescu roger.demetre...@gmail.com wrote: Note that this implementation is very simple. Depending of your use case, you probably should take a look at MutableType [1] and types.TypeEngine.is_mutable(). [1]

[sqlalchemy] Re: Inspecting DDL of a Table object, without executing the code

2009-02-28 Thread Michael Bayer
see the recipe in http://www.sqlalchemy.org/trac/wiki/FAQ#HowcanIgettheCREATETABLEDROPTABLEoutputasastring . On Feb 27, 2009, at 4:32 AM, Alex Willmer wrote: I suspect the answer to this is obvious, but it eludes me. I have defined some SQlAlchemy table classes, using declarative_base,

[sqlalchemy] Re: Filtering by an attribute of a related class (abusing generative filters...)

2009-02-28 Thread Michael Bayer
On Feb 27, 2009, at 3:10 PM, Ben Zealley wrote: Hi all, I've got a requirement that seems like it should be fairly straightforward, but my own attempts to work out the necessary code have just become more and more contrived, and still don't work :( so I'm hoping someone more familiar

[sqlalchemy] Re: foreignkey and relation synchronization

2009-02-28 Thread Michael Bayer
On Feb 27, 2009, at 3:51 PM, laurent wrote: Hello, There's a behaviour in SA that is not clear to me: if we look at the example (User and Address) from the docs, we can change either the related object or the foreign key For example: ad = Address(email_address='j...@google.com')

[sqlalchemy] Re: export and import JSON from database (JSON type)

2009-02-28 Thread Michael Bayer
On Feb 27, 2009, at 11:24 PM, eLuke wrote: I have a simple model/class named Comment with columns id (int), comment (text), and postdate (datetime). Below are the main bits of the python code I'm using to test how I should handle this: # json from the client's browser json =

[sqlalchemy] Re: Filtering by an attribute of a related class (abusing generative filters...)

2009-02-28 Thread Ben Zealley
Hi Michael, Thanks for the quick response! I had no luck with has()/any() mostly because I didn't have the attribute per se, just its (string) name - but I've rather belatedly realised I can just use modelClass.__dict__[attr].any(), which works like a charm. I'll consider the functional

[sqlalchemy] Re: Filtering by an attribute of a related class (abusing generative filters...)

2009-02-28 Thread Michael Bayer
On Feb 28, 2009, at 12:26 PM, Ben Zealley wrote: Hi Michael, Thanks for the quick response! I had no luck with has()/any() mostly because I didn't have the attribute per se, just its (string) name - but I've rather belatedly realised I can just use modelClass.__dict__[attr].any(), which