本文整理汇总了Python中models.Person.create方法的典型用法代码示例。如果您正苦于以下问题:Python Person.create方法的具体用法?Python Person.create怎么用?Python Person.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Person
的用法示例。
在下文中一共展示了Person.create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_fake_persons
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import create [as 别名]
def create_fake_persons(person_number=1):
try:
for x in xrange(person_number):
fname = str(random.choice(first_names))
lname = str(random.choice(last_names)) + str(random.choice(last_names).lower())
email = "%s.%[email protected]%s" % (fname.lower(), lname.lower(), str(random.choice(email_providers)))
gender = str(random.choice(genders))
city = str(random.choice(cities))
age = random.randint(18, 105)
Person.create(first_name=fname, last_name=lname, email=email, city=city, age=age, gender=gender)
return True
except:
return False
示例2: person
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import create [as 别名]
def person(self):
cookie, is_new_cookie = self.get_cookie()
if is_new_cookie:
person = Person.create(cookie)
else:
person = Person.get_by_cookie(cookie)
return person
示例3: main
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import create [as 别名]
def main(argv):
db.connect()
try:
Person.drop_table()
except sqlite3.OperationalError:
pass
Person.create_table()
with open(argv[1]) as f:
csv_file = DictReader(f)
for line in csv_file:
attrs = {
'trac_id': float(line['TRAC Assigned Identifier for Individual'].strip()),
'nationality': line['Nationality'].strip(),
'gender': line['Gender'].strip(),
}
try:
person = Person.select().where((Person.trac_id == attrs['trac_id']) & (Person.nationality == attrs['nationality'])).get()
except Person.DoesNotExist:
person = Person.create(**attrs)
示例4: create
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import create [as 别名]
def create():
form = PersonForm(request.form)
if request.method == 'POST' and form.validate():
person = Person.create(
firstname=form.firstname.data,
lastname=form.lastname.data,
birthday=form.birthday.data,
zipcode=form.zipcode.data)
if request.is_xhr:
return jsonify(success=True, person=person.serialize())
else:
return redirect(url_for('index'))
# if it's an ajax request and if fails
# form validation return message to client
if request.is_xhr and request.method == 'POST' and not form.validate():
return jsonify(success=False, errors=form.errors)
return render_template('create.html', form=form)
示例5: int
# 需要导入模块: from models import Person [as 别名]
# 或者: from models.Person import create [as 别名]
print e
return
register_time = active_status_list[1].contents[1] + ':00' # 注册时间
gender = soup.find_all('ul', class_='pf_l')[1].find_all(text='性别')[0].parent.next_sibling.strip()
statistics_list = soup.find(id='psts').find_all('li')
credits = int(statistics_list[1].contents[1]) # 积分
gold = int(statistics_list[2].contents[1]) # 金币
upload = int(statistics_list[3].contents[1]) # 上传量
download = int(statistics_list[4].contents[1]) # 下载量
seed = int(statistics_list[5].contents[1]) # 发种数
rp = int(statistics_list[8].contents[1]) # 人品
try:
Person.create(id=uid, name=name, online_time=online_time, register_time=register_time, credits=credits,
gold=gold, upload=upload, download=download, seed=seed, rp=rp, gender=gender)
print u'成功获取%d用户' % uid
except Exception, e:
print e
def queue_manager(self):
if self.queue.qsize < 10:
start_id = self.queue[-1]
for uid in xrange(start_id+1, start_id+101):
self.queue.put(uid)
while not self.queue.empty():
uid = self.queue.get()
self.get_people_info(uid=uid)
def work_queue(self):