当前位置: 首页>>代码示例>>Python>>正文


Python Structure.get_primary_key方法代码示例

本文整理汇总了Python中structure.Structure.get_primary_key方法的典型用法代码示例。如果您正苦于以下问题:Python Structure.get_primary_key方法的具体用法?Python Structure.get_primary_key怎么用?Python Structure.get_primary_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在structure.Structure的用法示例。


在下文中一共展示了Structure.get_primary_key方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: select

# 需要导入模块: from structure import Structure [as 别名]
# 或者: from structure.Structure import get_primary_key [as 别名]
 def select(self, *args):
     if args:
         map(lambda arg: self._check_is_instance(arg, 'Column'), args)
         args = list(args)
         args.append(Column(self._table_name, Structure.get_primary_key(self._table_name)))
         self._sql.add_select_args(args)
     return self._table_selected_instance()
开发者ID:davekr,项目名称:pypg,代码行数:9,代码来源:table.py

示例2: _get_fk_data

# 需要导入模块: from structure import Structure [as 别名]
# 或者: from structure.Structure import get_primary_key [as 别名]
 def _get_fk_data(self, table_name, fk, fk_value):
     reltable = Structure.get_fk_referenced_table(table_name, fk)
     reltable_pk = Structure.get_primary_key(reltable)
     if not self._cache.relation_exists(table_name, reltable):
         sql = SQLBuilder(reltable)
         sql.add_where_literal(Column(reltable, reltable_pk).in_(self._cache.get_all_keys(table_name, fk)))
         data = Query().execute_and_fetch(**sql.build_select())
         self._cache.save_relation(table_name, reltable, data)
     return Row(self._cache.get_relation_row(reltable, reltable_pk, fk_value), reltable, self)
开发者ID:davekr,项目名称:pypg,代码行数:11,代码来源:resultset.py

示例3: join

# 需要导入模块: from structure import Structure [as 别名]
# 或者: from structure.Structure import get_primary_key [as 别名]
 def join(self, table, on=None):
     self._check_is_instance(table, 'Table')
     if on:
         self._check_is_instance(on, 'Literal')
         self._validate_on(table, on)
     else:
         Structure.tables_related(self._table_name, table._table_name)
         try:
             fk = Structure.get_foreign_key_for_table(self._table_name, table._table_name)
         except PyPgException:
             fk = Structure.get_foreign_key_for_table(table._table_name, self._table_name)
             on = Column(table._table_name, fk) == \
                     Column(self._table_name, Structure.get_primary_key(self._table_name))
         else:
             on = Column(self._table_name, fk) == \
                     Column(table._table_name, Structure.get_primary_key(table._table_name))
     self._sql.add_join(table._table_name, on)
     return self._table_select_instance()
开发者ID:davekr,项目名称:pypg,代码行数:20,代码来源:table.py

示例4: __getattr__

# 需要导入模块: from structure import Structure [as 别名]
# 或者: from structure.Structure import get_primary_key [as 别名]
 def __getattr__(self, attr):
     self._check_deleted()
     if Structure.is_foreign_key(self._table_name, attr):
         if self._result_set:
             return self._result_set._get_fk_data(self._table_name, attr, self.data[attr])
         else:
             reltable = Structure.get_fk_referenced_table(self._table_name, attr)
             reltable_pk = Structure.get_primary_key(reltable)
             sql = SQLBuilder(reltable)
             sql.add_where_condition(reltable_pk, self.data[attr])
             data = Query().execute_and_fetch(**sql.build_select())
             return Row(data[0], reltable)
     else:
         self._check_relation_exists(attr)
         pk = self._get_pk()
         if self._result_set:
             return self._result_set._get_rel_data(self._table_name, attr, pk, self.data[pk])
         else:
             self._restricted_table_attr = attr
             from restricted import RestrictedTableSelect
             return RestrictedTableSelect(attr, SQLBuilder(attr), self)
开发者ID:davekr,项目名称:pypg,代码行数:23,代码来源:row.py

示例5: _get_pk

# 需要导入模块: from structure import Structure [as 别名]
# 或者: from structure.Structure import get_primary_key [as 别名]
 def _get_pk(self):
     pk= Structure.get_primary_key(self._table_name)
     if self.data.get(pk) is not None:
         return pk
     else:
         raise PyPgException('Incorectly formated naming for primary key. Please provide manager.Naming instance or set strict mode on.')
开发者ID:davekr,项目名称:pypg,代码行数:8,代码来源:row.py


注:本文中的structure.Structure.get_primary_key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。