在 Elixir 或 SQLAlchemy 中,是否有一种方法可以存储实体中每个字段的注释?
我们的项目基本上是多个记录系统的网络界面。我们映射了许多表,并且每列的名称没有像我们希望的那样命名和直观...用户想知道哪些数据字段可用(即从数据库映射的内容)。但是,仅仅给它们提供列名是没有意义的:USER_REF1、USER_REF2 等。
所以,我想知道,有没有办法在我的字段声明中提供注释?
例如,
class SegregationCode(Entity):
using_options(tablename="SEGREGATION_CODES")
segCode = Field(String(20), colname="CODE", ...
primary_key=True) #Have a comment attr too?
如果没有,有什么建议吗?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过 SQLAlchemy 文档 进行一些研究,我和我的朋友发现一行内容说 Column 对象有一个名为
info
的默认字典,它是存储“应用程序特定数据”的空间。所以,就我而言,我可以做类似的事情: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: