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


Python InsertableRecord.include_ix方法代码示例

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


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

示例1: import_users

# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import include_ix [as 别名]
    def import_users(self, ignore_errors=False):
        table_name = "users"
        LOGGER.info("importing %s"% table_name)

        try:
            filepath = os.path.abspath(
                os.path.join(self.import_directory, "%s.xml"% table_name))
            dom = minidom.parse(filepath)
        except IOError:
            LOGGER.error(
            "Unable to import users - no such file %s"% filepath)
            raise self.ImportWarning

        record = InsertableRecord(self.om2_session, table_name)
        record.include_ix = True
        record.remove(record.indexOf("time_stamp"))
        ps_query, values = record.insert_query
        psql_query = QtSql.QSqlQuery(self.om2_session)

        rows = dom.getElementsByTagName(table_name.rstrip("s"))

        errors_encountered = False
        for row in rows:
            psql_query.prepare(ps_query)
            for node in ('ix', 'abbrv_name', 'role', 'title', 'last_name',
            'middle_name', 'first_name', 'qualifications', 'registration',
            'correspondence_name', 'sex', 'dob',
            'status', 'comments', 'avatar_id', 'display_order'):
                vals = row.getElementsByTagName(node)
                try:
                    val = vals[0].firstChild.data.strip()
                    if node == "ix":
                        ix = int(val)
                    elif node == "abbrv_name":
                        user = val
                        self.USER_DICT[user] = ix

                except IndexError:
                    val = None
                except AttributeError:
                    val = ""
                psql_query.addBindValue(val)

            psql_query.addBindValue("imported from xml")
            psql_query.exec_()
            if not ignore_errors and psql_query.lastError().isValid():
                LOGGER.warning("ERROR IMPORTING User \n\t%s\t%s"% (
                    row.toprettyxml(),
                    psql_query.lastError().text()))
                errors_encountered = True

        LOGGER.debug(self.USER_DICT)
        if errors_encountered:
            raise self.ImportWarning
        self.register_progress("import_users", 100)
开发者ID:atarist,项目名称:openmolar2,代码行数:57,代码来源:importer.py

示例2: import_practitioners

# 需要导入模块: from lib_openmolar.common.db_orm import InsertableRecord [as 别名]
# 或者: from lib_openmolar.common.db_orm.InsertableRecord import include_ix [as 别名]
    def import_practitioners(self):
        table_name = "practitioners"
        LOGGER.info("importing %s"% table_name)

        try:
            filepath = os.path.abspath(
                os.path.join(self.import_directory, "%s.xml"% table_name))
            dom = minidom.parse(filepath)
        except IOError as exc:
            LOGGER.error(
            "Unable to import practitioners - no such file %s"% filepath)
            raise _ImportWarning

        record = InsertableRecord(self.om2_session, table_name)
        record.include_ix = True

        record.remove(record.indexOf("time_stamp"))
        ps_query, values = record.insert_query
        psql_query = QtSql.QSqlQuery(self.om2_session)

        rows = dom.getElementsByTagName(table_name.rstrip("s"))

        for row in rows:
            psql_query.prepare(ps_query)
            for node in ("ix", "user_id", "type", "speciality",
             "status", "comments", ):
                vals = row.getElementsByTagName(node)
                try:
                    val = vals[0].firstChild.data.strip()
                except IndexError:
                    val = None
                except AttributeError:
                    val = ""
                psql_query.addBindValue(val)

            psql_query.addBindValue("imported from xml")
            psql_query.exec_()
            if psql_query.lastError().isValid():
                LOGGER.warning("ERROR IMPORTING %s - %s"% (
                    row.toxml(),
                    psql_query.lastError().text()))
        self.register_progress("import_practitioners", 100)
开发者ID:atarist,项目名称:openmolar2,代码行数:44,代码来源:importer.py


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