Hi Petr,

I think if you are the owner of the database schema, you can grant
select, update, delete only to the columns that you want from MySQL/
Oracle/PostgreSQL/MS-SQL.  I think this is something done on the
database side of things, not in SQLAlchemy.  I checked the
documentation of SQLAlchemy and couldn't find anything on setting
readonly to a certain specific column.

If there is a method, I'd love to hear more about it.

Just my $0.02.

 -Mark

On Aug 30, 6:37 pm, Petr Kobalíček <kobalicek.p...@gmail.com> wrote:
> I have small question regarding the viewonly property. Can I assign
> viewonly to a column? In the SqlA example it's used together with
> relationship(), I need to mark viewonly just table column.
>
> For example:
>
> RecordTable = Table('t_record', metadata,
>   Column('record_id', Integer, primary_key = True),
>   Column('idx', Integer, default=None),
>   Column('msg', UnicodeText)
> )
>
> class RecordModel(object):
>   def __init__(self, msg = u""):
>     self.msg = msg
>
>   def __repr__(self):
>     return u"REC - Idx(" + unicode(self.idx) + u"), Msg(" + self.msg + u")"
>
> orm.mapper(RecordModel, RecordTable,
>   properties = {
>     "id": RecordTable.c.record_id,
>     "idx": RecordTable.c.idx,  #### MARK ReadOnly? ####
>     "msg": RecordTable.c.msg
>   }
> )
>
> Thanks a lot
>
> Best regards
> Petr Kobalicek
>
> On Mon, Aug 30, 2010 at 4:51 AM, Petr Kobalíček<kobalicek.p...@gmail.com> 
> wrote:
> > Hi devs,
>
> > thanks for replies!
>
> > Michael: I asked probably wrong question. I know how to make property
> > read-only in Python, but I wanted the property to be read-only at ORM
> > level (so it will not appear in UPDATE).
>
> > Mark: This is probably is solution to my problem.
>
> > I'm trying to create an abstract wrapper for ordered-list records. I
> > wanted to post example which describes what I'm doing, but I will
> > create another topic when basic features will be working.
>
> > Best regards
> > Petr
>
> > On Mon, Aug 30, 2010 at 3:59 AM, Mark <zhengha...@gmail.com> wrote:
> >> Hi Petr,
>
> >> You may want to have a look at this link
> >>http://www.sqlalchemy.org/docs/mappers.html#building-query-enabled-pr...
>
> >> Setting the viewonly=True property in your mapper configuration does
> >> exactly what you want.  I've used it a couple of times in my own
> >> project and it works.
>
> >> -Mark
>
> >> On Aug 29, 10:00 pm, Petr Kobalíček <kobalicek.p...@gmail.com> wrote:
> >>> Hi devs,
>
> >>> is there a simple way how to make an ORM property read only? I need to
> >>> fetch the column from database so it will be accessible through the
> >>> mapped class, but I need that the property will be never updated back
> >>> to the database (in case I add the object to the session and do
> >>> commit).
>
> >>> Thanks!
>
> >>> Best regards
> >>> Petr Kobalicek
>
> >> --
> >> 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+unsubscr...@googlegroups.com.
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/sqlalchemy?hl=en.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to