Good day,

I'm trying to figure out how to do something similar to the Symmetric
Encryption recipe (http://www.sqlalchemy.org/trac/wiki/UsageRecipes/
SymmetricEncryption), only on the database side, not in Python.

I have a suspicion that @compiles decorator may provide a solution,
but having trouble understaning how to apply it to my case.

For simplicity, let's imagine a field which stores data in upper case
but always returns it in lower case... so it needs to generate SQL
similar to

"INSERT INTO tablename VALUES (..., upper(...), ...)"

on insert and

"SELECT ..., lower(fieldname) as fieldname, ... FROM tablename"

on select.

I'm using orm and I imagine the final result would look like

class MyModel(Base):
    ...
    myfield = AlwaysLowercaseColumn(sqlalchemy.String)

or

class MyModel(Base):
    ...
    myfield = sqlalchemy.Column(AlwaysLowercaseString)

Thanks,
Sergey

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

Reply via email to