本文整理汇总了Python中models.User.User.id方法的典型用法代码示例。如果您正苦于以下问题:Python User.id方法的具体用法?Python User.id怎么用?Python User.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.User.User
的用法示例。
在下文中一共展示了User.id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import id [as 别名]
def main():
print 'Hello World'
myDB = MysqlPython('thinkman-wang.com', 'thinkman', 'Ab123456', 'db_thinknews')
szSql = 'select * from user'
result = myDB.select_advanced(szSql)
for obj in result :
user = User()
user.id, user.user_name, user.password = obj
print("%d | %s | %s" % (user.id, user.user_name, user.password))
lstUser = get_all_users()
for user in lstUser :
print("%d | %s | %s" % (user.id, user.user_name, user.password))
lstUser = get_all_user_from_pool();
for user in lstUser :
print("%d | %s | %s" % (user.id, user.user_name, user.password))
print obj2json(lstUser)
user = login("18621675203", "a0a475cf454cf9a06979034098167b9e")
if (user != None):
print obj2json(user)
else:
print("login failed")
szToken = ("%s%d" % ("a0a475cf454cf9a06979034098167b9e", int(time.time())))
print(hashlib.md5(szToken).hexdigest())
示例2: user_login
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import id [as 别名]
def user_login(user_name, password):
conn = g_dbPool.connection()
cur=conn.cursor()
cur.execute("select * from view_user where user_name=%s AND password=%s" , (user_name, password))
#cur.execute("select * from view_user where user_name=\"18621675203\" AND password=\"a0a475cf454cf9a06979034098167b\"")
rows=cur.fetchall()
lstUser = []
for row in rows:
user = User()
user.id = row[0]
user.user_name = row[1]
user.password = row[2]
user.token = row[3]
user.create_time = row[4]
user.expire_time = row[5]
lstUser.append(user)
cur.close()
if (lstUser != None and len(lstUser) >= 1):
userRet = lstUser[0]
userRet = insert_or_update_token(userRet)
return userRet
else:
return None
示例3: get_all_users
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import id [as 别名]
def get_all_users() :
myDB = MysqlPython('thinkman-wang.com', 'thinkman', 'Ab123456', 'db_thinknews')
szSql = 'select * from user'
result = myDB.select_advanced(szSql)
lstUser = []
for obj in result :
user = User()
user.id, user.user_name, user.password = obj
lstUser.append(user)
return lstUser
示例4: get_all_user_from_pool
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import id [as 别名]
def get_all_user_from_pool():
conn = g_dbPool.connection()
cur=conn.cursor()
SQL="select * from user"
cur.execute(SQL)
rows=cur.fetchall()
lstUser = []
for row in rows:
user = User()
user.id = row[0]
user.user_name = row[1]
user.password = row[2]
lstUser.append(user)
cur.close()
return lstUser
示例5: create
# 需要导入模块: from models.User import User [as 别名]
# 或者: from models.User.User import id [as 别名]
def create():
if request.method=="POST":
check=True
if not 'nick' in request.form:
check=False
if not 'id' in request.form:
check=False
if not 'pw' in request.form:
check=False
if not check:
return render_template('signup.html', notenough=True)
new=User()
new.id=request.form['id']
new.name=request.form['nick']
new.password=request.form['pw']
db.session.add(new)
db.session.commit()
return redirect('/login')
return render_template('signup.html')