[sqlalchemy] Joins with 3 tables to order results?

2007-03-01 Thread Chris Shenton
I've got a 'system' table which has a foreign key client_id to a 'client' table, and that has a FK vendor_id to a 'vendor' table. Currently I query and order by client_id and system attribute like:: systems = self.session.query(System).select(or_(System.c.lastseen == None,

[sqlalchemy] [Solved] Avoiding SQL injection with raw-ish queries (MySQL FULLTEXT search)

2007-01-28 Thread Chris Shenton
I finally discovered the Using Bind Parameters in Text Blocks section of the SQLAlchemy manual -- very useful and very easy to use. Perhaps this will help others who are trying to search against MySQL's FULLTEXT index safely. FWIW, I'm doing this in Pylons. Here's what I ended up doing: t

[sqlalchemy] Avoiding SQL injection with raw-ish queries (MySQL FULLTEXT search)

2007-01-28 Thread Chris Shenton
I'm doing a query against a MySQL table that has a column which has a fulltext index, so I need to do some raw-ish queries. Problem is that these open me up to SQL injection attacks. How do I avoid them -- bound variables? filtering of quotes and funny chars? I create the index on a table

[sqlalchemy] Re: Full Text Search using PostgreSQL and tsearch2

2007-01-18 Thread Chris Shenton
I'd be interested in how you work this out as I want to do something similar. Would you be willing to write it up and perhaps post it to the wiki? I was able to get MySQL's fulltext search working more quickly than PostgreSQL's and that's what my customer is used to so that's what I'm going to

[sqlalchemy] How to query like sys_id=42 AND ts_created 90 minutes ago ?

2007-01-11 Thread Chris Shenton
I've got a bunch of history and other timestamped information I will need to query against. The columns are created with type DateTime and get set upon row creation: history_table = Table( 'history', metadata, Column('history_id', Integer,primary_key=True),

[sqlalchemy] Additions to model not getting flushed to DB?? (Pylons)

2006-12-23 Thread Chris Shenton
I'm doing a Pylons app and must be doing something stupid because similar logic seems to work elsewhere, but this just isn't sticking in the DB. I query to get existing 'contacts', they're empty so I create a new one, append it, save and flush, but it doesn't show up in the diagnostic queries I

[sqlalchemy] Re: Additions to model not getting flushed to DB?? (Pylons)

2006-12-23 Thread Chris Shenton
Doh, I should have turned on the SQL echo. Now that I have, it's even more puzzling to me. It shows the 'contact' being inserted and committed -- but it never appears in MySQL! 2006-12-23 17:33:15,140 INFO sqlalchemy.engine.base.Engine.0x..cc BEGIN 2006-12-23 17:33:15,145 INFO

[sqlalchemy] Re: Additions to model not getting flushed to DB?? (Pylons)

2006-12-23 Thread Chris Shenton
Michael Bayer [EMAIL PROTECTED] writes: seems like Pylons is not properly maintaining the session within requests. Yeah, it sure feels like that. :-( unless there is some way you can reproduce this problem without any dependencies on pylons ? is this using the newest SA/Pylons code that

[sqlalchemy] Re: How to auto-set timestamp: MySQL func.now(), but not SQLite

2006-12-22 Thread Chris Shenton
Michael Bayer [EMAIL PROTECTED] writes: func.current_timestamp() (which evaulates without the parenthesis in SQL) Excellent, works like a charm. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups