本文整理匯總了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)