On May 25, 2010, at 9:50 AM, daniel wrote:

> Hi...
> 
> I'm having some trouble with creating a select statement with a where
> clause that uses a literal value ... in the process of debugging i've
> narrowed it down to the way the interpreter treats the == operator
> when bound to an sqlite database (this problem goes away when I use
> oracle). Basically, if I print the statement:
> 
> print bondData.c.NORTHINFO_RATING == "AAA"
> 
> I get:
> 
> "BOND_DATA"."NORTHINFO_RATING" = ?
> 
> which, when used as a where clause in a query, produces no records
> whereas when i use oracle via cx_oracle, the statement
> 
> print bondData.c.northinfo_rating == "AAA"
> 
> gives me:
> 
> "BOND_DATA".northinfo_rating = :northinfo_rating_1
> 
> which produces a query that returns a data set from the table
> "BOND_DATA" where values of the column northinfo_rating = "AAA"...
> This clearly is the desired result...
> 
> Any tips as to what I'm doing wrong wrong in the sqlite case?

not at all, the clause is correct for SQLite.  the pysqlite driver defaults to 
the "qmark" style of bind parameter, whereas cx_oracle defaults to "named"  
(hence '?' in one case and ':some_name' for the other).

> 
> BTW... the capitalization of the column names is different for the two
> databases because I've realized by trial and error that oracle column
> names should be in lower case whereas sqlite column names should be in
> whatever letter-case they were specified in the DB...

this is due to the usage of uppercase characters in the column name.   By using 
them, you tell SQLalchemy that the name is "case sensitive", and that all 
casing should be preserved.   This is described at 
http://www.sqlalchemy.org/docs/reference/sqlalchemy/schema.html?highlight=column#sqlalchemy.schema.Column
 .   It's not clear why your examples use c.NORTHINFO_RATING in one example, 
and c.northinfo_rating in the other - these are not synonymous.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to