本文整理匯總了Python中models.SqlHandler.addItems方法的典型用法代碼示例。如果您正苦於以下問題:Python SqlHandler.addItems方法的具體用法?Python SqlHandler.addItems怎麽用?Python SqlHandler.addItems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.SqlHandler
的用法示例。
在下文中一共展示了SqlHandler.addItems方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: init
# 需要導入模塊: from models import SqlHandler [as 別名]
# 或者: from models.SqlHandler import addItems [as 別名]
def init(status):
if not status:
session = SqlHandler.newSession()
SqlHandler.addItems(session,[SqlHandler.ALV(alv=24,alv_class=1), #Normal items
SqlHandler.ALV(alv=10,alv_class=2), #Medicines
SqlHandler.ALV(alv=14,alv_class=3)]) #Feed
SqlHandler.addItems(session, [SqlHandler.GlobalVar(key="clinicpayment", value="20.00"),
SqlHandler.GlobalVar(key="km_price", value="0.48")])
#create species
koira = SqlHandler.Specie('Koira')
kissa = SqlHandler.Specie('Kissa')
hevonen = SqlHandler.Specie('Hevonen')
#add species
SqlHandler.addItems(session, [koira, kissa, hevonen])
item_list = []
dogs_file_name = "koirarodut.txt"
cats_file_name = "kissarodut.txt"
horse_file_name = "hevosrodut.txt"
try:
f = open(dogs_file_name, "r", encoding="utf-8")
for race_name in f.readlines():
item_list.append(SqlHandler.Race(race_name.strip(),koira.id))
f.close()
except IOError:
print("Can not find file named: " + dogs_file_name)
pass
try:
f = open(cats_file_name, "r", encoding="utf-8")
for race_name in f.readlines():
item_list.append(SqlHandler.Race(race_name.strip(),kissa.id))
f.close()
except IOError:
print("Can not find file named: "+ cats_file_name)
pass
try:
f = open(horse_file_name, "r", encoding="utf-8")
for race_name in f.readlines():
item_list.append(SqlHandler.Race(race_name.strip(),hevonen.id))
f.close()
except IOError:
print("Can not find file named: "+ cats_file_name)
pass
SqlHandler.addItems(session,item_list)
try:
f = open('postinumerot.txt', "r", encoding="utf-8")
raw_p_data = f.readlines()
offices = []
offices_dict = {}
for line in raw_p_data:
if len(line) > 1:
office = SqlHandler.PostOffice(line.split(' ')[0])
offices.append(office)
offices_dict[line.split(' ')[0]] = office;
SqlHandler.addItems(session,offices)
numbers = []
for line in raw_p_data:
if len(line) > 1:
for item in line.split(' ')[1].strip().split(','):
numbers.append(SqlHandler.PostNumber(offices_dict[line.split(' ')[0]].id, int(item)))
SqlHandler.addItems(session,numbers)
f.close()
except IOError:
print("Can not find file named: "+ cats_file_name)
pass