[sqlalchemy] unittest assertRaises does not catch NoResultFound

2011-01-11 Thread pr64
Hi, New with sqlalchemy, i'm trying to unittest my code: import unittest import os from sqlalchemy.orm.exc import NoResultFound import User SQLITE_FILE = 'test.db' class UserAddTestCase(unittest.TestCase): def setUp(self): ... some code which create the session (removed to be

[sqlalchemy] ObjectDeletedError

2011-01-11 Thread Erkan Özgür Yılmaz
Hi all, This is my first question regarding to SQLAlchemy, you can count me as a newbie. Here is my problem: I've this inheritance between my Python classes, everything were working fine until last night when I've added another class to my inheritance hierarchy. I've tried to find the cause of

[sqlalchemy] Generating Raw SQL statements with parameters included

2011-01-11 Thread Harkirat
Hi All, DELETE FROM appname WHERE appname.appid = ? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to

[sqlalchemy] Generating Raw SQL statements with parameters included

2011-01-11 Thread Harkirat
Hi All, DELETE FROM appname WHERE appname.appid = ? -- You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to

[sqlalchemy] Generating Raw SQL statements with parameters included

2011-01-11 Thread Harkirat
Hi All, When I run this delete_stmt = appname.delete(appname.c.appid==1) print delete_stmt I get output DELETE FROM appname WHERE appname.appid = ? Is there any way I can print out raw sql statments with the parameters included e.g. DELETE FROM appname WHERE appname.appid = 1 Thanks!

Re: [sqlalchemy] ObjectDeletedError

2011-01-11 Thread Michael Bayer
On Jan 11, 2011, at 8:51 AM, Erkan Özgür Yılmaz wrote: Hi all, This is my first question regarding to SQLAlchemy, you can count me as a newbie. Here is my problem: I've this inheritance between my Python classes, everything were working fine until last night when I've added another

Re: [sqlalchemy] unittest assertRaises does not catch NoResultFound

2011-01-11 Thread Michael Bayer
On Jan 11, 2011, at 4:56 AM, pr64 wrote: self.assertEqual(self.session.query(User).filter(User.firstname == user1_fn).count(), 1) self.assertRaises(NoResultFound, self.session.query(User).filter(User.firstname == other_fn).one()) assertRaises receives a callable, which when

Re: [sqlalchemy] Re: partial rollback in transaction ?

2011-01-11 Thread Michael Bayer
On Jan 10, 2011, at 6:09 PM, Romy wrote: Not sure what you mean, as I've seen hybrid setups before. I'm pretty sure if you try to make a foreign key from an InnoDB table to a MyISAM table, it will fail. In any case, thanks for helping me narrow this down. I need to decide whether I'll

Re: [sqlalchemy] ObjectDeletedError

2011-01-11 Thread Erkan Özgür Yılmaz
Great, adding the primary_key=True to the linkTypes table solved my problem, thank you very much... Cheers... E.Ozgur Yilmaz Lead Technical Director eoyilmaz.blogspot.com www.ozgurfx.com On Tue, Jan 11, 2011 at 5:24 PM, Michael Bayer mike...@zzzcomputing.comwrote: On Jan 11, 2011, at 8:51

Re: [sqlalchemy] Generating Raw SQL statements with parameters included

2011-01-11 Thread Michael Bayer
This question comes up from time to time and I'm generally extremely uncomfortable documenting it, as SQLAlchemy carefully protects its reputation as being 100% bind-parameter driven and in no way wants to encourage the rendering of data directly into SQL strings.This is the one real area

[sqlalchemy] Re: Generating Raw SQL statements with parameters included

2011-01-11 Thread Harkirat
Thank you! I understand the security concerns. I only need this for testing purposes and production will be all bind-parameter driven. On Jan 11, 11:15 am, Michael Bayer mike...@zzzcomputing.com wrote: This question comes up from time to time and I'm generally extremely uncomfortable

Re: [sqlalchemy] Re: Generating Raw SQL statements with parameters included

2011-01-11 Thread Timuçin Kızılay
I'm using SA with turbogears 2.x framework and in development mode when I turn on all the logging I can see the generated SA queries in the paste web server console. And one line after the generated query, there is a line which shows the parameters. here is a sample output:

[sqlalchemy] Database Reflection - Forcing column names to be lowercase?

2011-01-11 Thread Harkirat
Hi, Is there any way that anyone knows of to force the column names to be lowercase when reflecting the schema from the database for e.g. appname = Table('appname', metadata, autoload=True) Other posts suggested overriding the database schema with your own but I would rather use SQLAlchemy's

[sqlalchemy] Re: Generating Raw SQL statements with parameters included

2011-01-11 Thread Harkirat
Thanks Timuçin. I know of the logging functionality by setting echo=True but I wanted to avoid the ? inside the query and have the parameters instead without me having to do it manually so I could copy the entire query string and execute it as is on the database. Michal's wiki post solved that for

Re: [sqlalchemy] Database Reflection - Forcing column names to be lowercase?

2011-01-11 Thread Michael Bayer
There's no straightforward way to do that. Schemes to copy each Table to a new one with a lowercase .key attribute, using Inspector to generate the Table object programatically (basically means, implement your own Inspector.reflecttable()), subclassing Inspector (since it currently calls