On Mar 19, 2009, at 7:50 PM, loctones wrote:
>
> I'm moving the database which drives a program from MySQL to Oracle.
> The original implementation of the database columns was in CamelCase.
> My company dictates that all caps be used for column names.
>
> In the sqlalchemy documentation, I found this quote:
> Names which contain no upper case characters will be treated as case
> insensitive names, and will not be quoted unless they are a reserved
> word. Names with any number of upper case characters will be quoted
> and sent exactly. Note that this behavior applies even for databases
> which standardize upper case names as case insensitive such as Oracle.
>
> When I reflect my tables from the Oracle database, I get column names
> that are all lowercase. But the leftover CamelCase style causes the
> operations to be case sensitive, and I get failures regarding missing
> attributes, etc. Is there a simpler way around this problem than
> converting all of the CamelCase stuff to lowercase?
a search and replace of all your CamelCase names is definitely the
simplest way around this issue. Alternatively you would have to
forego the usage of reflection and rename your attributes using "key":
t = Table("mytable", metadata,
Column("somecolumn", Integer, key="SomeColumn")
)
or you can accomplish something similar with the ORM, if that's all
you needed:
mapper(MyClass, sometable, properties={
'SomeColumn':sometable.c.somecolumn
})
both of the above can be automated with custom code, and possibly even
can be built around the reflected tables. but you'd need some kind of
lowercase-to-CamelCase converter.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---