开发者

In Elixir or SQLAlchemy, is there a way to also store a comment for a/each field in my entities?

Our project is basically a web interface to several systems of record. We have many tables mapped, and the names of each column aren't as well named and intuitive as we'd like... The users would开发者_如何学JAVA like to know what data fields are available (i.e. what's been mapped from the database). But, it's pointless to just give them column names like: USER_REF1, USER_REF2, etc.

So, I was wondering, is there a way to provide a comment in the declaration of my field?

E.g.

class SegregationCode(Entity):
    using_options(tablename="SEGREGATION_CODES")
    segCode = Field(String(20), colname="CODE", ...
                    primary_key=True) #Have a comment attr too?

If not, any suggestions?


Doing some research thru the SQLAlchemy documentation, my buddy and I found a line that says the Column object has a default dictionary called info that is a space to store "application specific data." So, in my case, I can just doing something like:

class SegregationCode(Entity):
    using_options(tablename="SEGREGATION_CODES")
    segCode = Field(String(20), colname="CODE", ...
                    primary_key=True, info={'description'='Segregation Code'})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜