本文整理汇总了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)
示例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)