<legend id='iwfwD'><style id='iwfwD'><dir id='iwfwD'><q id='iwfwD'></q></dir></style></legend>
  • <tfoot id='iwfwD'></tfoot>
    1. <i id='iwfwD'><tr id='iwfwD'><dt id='iwfwD'><q id='iwfwD'><span id='iwfwD'><b id='iwfwD'><form id='iwfwD'><ins id='iwfwD'></ins><ul id='iwfwD'></ul><sub id='iwfwD'></sub></form><legend id='iwfwD'></legend><bdo id='iwfwD'><pre id='iwfwD'><center id='iwfwD'></center></pre></bdo></b><th id='iwfwD'></th></span></q></dt></tr></i><div id='iwfwD'><tfoot id='iwfwD'></tfoot><dl id='iwfwD'><fieldset id='iwfwD'></fieldset></dl></div>
        <bdo id='iwfwD'></bdo><ul id='iwfwD'></ul>

      <small id='iwfwD'></small><noframes id='iwfwD'>

        如何从 SQLAlchemy 映射对象中发现表属性

        How to discover table properties from SQLAlchemy mapped object(如何从 SQLAlchemy 映射对象中发现表属性)

        1. <tfoot id='uaduU'></tfoot>

            <small id='uaduU'></small><noframes id='uaduU'>

            <legend id='uaduU'><style id='uaduU'><dir id='uaduU'><q id='uaduU'></q></dir></style></legend>
            • <bdo id='uaduU'></bdo><ul id='uaduU'></ul>

                  <tbody id='uaduU'></tbody>
                • <i id='uaduU'><tr id='uaduU'><dt id='uaduU'><q id='uaduU'><span id='uaduU'><b id='uaduU'><form id='uaduU'><ins id='uaduU'></ins><ul id='uaduU'></ul><sub id='uaduU'></sub></form><legend id='uaduU'></legend><bdo id='uaduU'><pre id='uaduU'><center id='uaduU'></center></pre></bdo></b><th id='uaduU'></th></span></q></dt></tr></i><div id='uaduU'><tfoot id='uaduU'></tfoot><dl id='uaduU'><fieldset id='uaduU'></fieldset></dl></div>
                  本文介绍了如何从 SQLAlchemy 映射对象中发现表属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个用表映射的类,在我的例子中是声明式的,我想从这个类中发现"表属性、列、名称、关系:

                  I have a class mapped with a table, in my case in a declarative way, and I want to "discover" table properties, columns, names, relations, from this class:

                  engine = create_engine('sqlite:///' + databasePath, echo=True)
                  
                  # setting up root class for declarative declaration
                  Base = declarative_base(bind=engine)
                  
                  class Ship(Base):
                      __tablename__ = 'ships'
                  
                      id = Column(Integer, primary_key=True)
                      name = Column(String(255))
                  
                      def __init__(self, name):
                              self.name = name
                  
                      def __repr__(self):
                              return "<Ship('%s')>" % (self.name)
                  

                  所以现在我的目标是从Ship"类从另一段代码中获取表列及其属性.我想我可以使用检测来处理它,但是 SQLAlchemy API 是否提供了任何方法?

                  So now my goal is from the "Ship" class to get the table columns and their properties from another piece of code. I guess I can deal with it using instrumentation but is there any way provided by the SQLAlchemy API?

                  推荐答案

                  您需要的信息可以从 表 对象:

                  Information you need you can get from Table object:

                  • Ship.__table__.columns 将为您提供栏目信息
                  • Ship.__table__.foreign_keys 将列出外键
                  • Ship.__table__.constraintsShip.__table__.indexes 是您可能会觉得有用的其他属性
                  • Ship.__table__.columns will provide you with columns information
                  • Ship.__table__.foreign_keys will list foreign keys
                  • Ship.__table__.constraints, Ship.__table__.indexes are other properties you might find useful

                  这篇关于如何从 SQLAlchemy 映射对象中发现表属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  SQLite loop statements?(SQLite 循环语句?)
                  Can I use parameters for the table name in sqlite3?(我可以在 sqlite3 中使用表名的参数吗?)
                  SQL - Inserting a row and returning primary key(SQL - 插入一行并返回主键)
                  How to get the number of rows of the selected result from sqlite3?(如何从sqlite3中获取所选结果的行数?)
                  Python : How to insert a dictionary to a sqlite database?(Python:如何将字典插入到 sqlite 数据库中?)
                  What are the advantages of VistaDB(VistaDB有什么优势)

                  1. <i id='9R5zM'><tr id='9R5zM'><dt id='9R5zM'><q id='9R5zM'><span id='9R5zM'><b id='9R5zM'><form id='9R5zM'><ins id='9R5zM'></ins><ul id='9R5zM'></ul><sub id='9R5zM'></sub></form><legend id='9R5zM'></legend><bdo id='9R5zM'><pre id='9R5zM'><center id='9R5zM'></center></pre></bdo></b><th id='9R5zM'></th></span></q></dt></tr></i><div id='9R5zM'><tfoot id='9R5zM'></tfoot><dl id='9R5zM'><fieldset id='9R5zM'></fieldset></dl></div>

                      <legend id='9R5zM'><style id='9R5zM'><dir id='9R5zM'><q id='9R5zM'></q></dir></style></legend>

                          <tbody id='9R5zM'></tbody>
                      • <small id='9R5zM'></small><noframes id='9R5zM'>

                      • <tfoot id='9R5zM'></tfoot>

                          <bdo id='9R5zM'></bdo><ul id='9R5zM'></ul>