当前位置: 首页>>代码示例>>Python>>正文


Python Dao.execute方法代码示例

本文整理汇总了Python中models.dao.Dao.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Dao.execute方法的具体用法?Python Dao.execute怎么用?Python Dao.execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.dao.Dao的用法示例。


在下文中一共展示了Dao.execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def add(d):
     del d['id']
     sql = "INSERT INTO assignments (%s) VALUES (%s);" % (
         ','.join(d.keys()), '?' + ',?' * (len(d) - 1)
     )
     vals = list(d.values())
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:9,代码来源:assignment.py

示例2: login

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def login(username, password):
     sql = "SELECT * FROM users WHERE username=?;"
     vals = (username, )
     rex = Dao.execute(sql, vals)
     if not rex or len(rex) != 1:
         raise Exception('Invalid login!')
     if not User.__verify_pw(password, rex[0]['password']):
         raise Exception('Invalid login!')
     return rex[0]
开发者ID:joegillon,项目名称:allocat,代码行数:11,代码来源:user.py

示例3: update

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def update(d):
     empid = d['id']
     del d['id']
     sql = ("UPDATE employees "
            "SET %s "
            "WHERE id=?;") % (
         ','.join(f + '=?' for f in d.keys()))
     vals = list(d.values()) + [empid]
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:11,代码来源:employee.py

示例4: update

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def update(d):
     asnid = d['id']
     del d['id']
     sql = ("UPDATE assignments "
            "SET %s "
            "WHERE id=?;") % (
         ','.join(f + '=?' for f in d.keys()))
     vals = list(d.values()) + [asnid]
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:11,代码来源:assignment.py

示例5: get_for_timeframe

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def get_for_timeframe(first_month, last_month):
     sql = ("SELECT a.id AS id, "
            "a.employee_id AS employee_id, "
            "a.project_id AS project_id, "
            "a.first_month AS first_month, "
            "a.last_month AS last_month, "
            "a.effort AS effort, "
            "e.name AS employee, "
            "p.nickname AS project "
            "FROM assignments AS a "
            "JOIN employees AS e ON a.employee_id=e.id "
            "JOIN projects AS p ON a.project_id=p.id "
            "WHERE a.first_month BETWEEN ? AND ? "
            "OR a.last_month BETWEEN ? AND ?;")
     vals = (first_month, last_month, first_month, last_month)
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:18,代码来源:assignment.py

示例6: get_for_project

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def get_for_project(prjid, month=None):
     sql = ("SELECT a.id AS id, "
            "a.employee_id AS employee_id, "
            "a.first_month AS first_month, "
            "a.last_month AS last_month, "
            "a.effort AS effort, "
            "a.notes AS notes, "
            "e.name AS employee "
            "FROM assignments AS a "
            "JOIN employees AS e ON a.employee_id= e.id "
            "WHERE a.project_id=? ")
     vals = [prjid]
     if month:
         sql += "AND a.last_month >= ? "
         vals += [month]
     sql += "ORDER BY e.name;"
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:19,代码来源:assignment.py

示例7: get_for_employee

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def get_for_employee(empid, month=None):
     sql = ("SELECT a.id AS id, "
            "a.project_id AS project_id, "
            "a.first_month AS first_month, "
            "a.last_month AS last_month, "
            "a.effort AS effort, "
            "a.notes AS notes, "
            "p.nickname AS project "
            "FROM assignments AS a "
            "JOIN projects AS p "
            "ON a.project_id= p.id "
            "WHERE a.employee_id=? ")
     vals = [empid]
     if month:
         sql += ("AND a.first_month <= ? "
                 "AND a.last_month >= ? ")
         vals += [month, month]
     sql += "ORDER BY p.nickname;"
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:21,代码来源:assignment.py

示例8: delete_role

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def delete_role(role_id):
     sql = "DELETE FROM roles WHERE id=?;"
     vals = (role_id,)
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:6,代码来源:user.py

示例9: get_all

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def get_all():
     sql = "SELECT * FROM employees ORDER BY name;"
     return Dao.execute(sql)
开发者ID:joegillon,项目名称:allocat,代码行数:5,代码来源:employee.py

示例10: add_user

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def add_user(d):
     sql = ("INSERT INTO users "
            "(username, password, role_id) "
            "VALUES (?,?,?);")
     vals = (d['username'], User.__hash_pw(d['password']), d['role_id'])
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:8,代码来源:user.py

示例11: update_role

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def update_role(d):
     sql = ("UPDATE roles "
            "SET name=?, description=? "
            "WHERE id=?;")
     vals = (d['name'], d['description'], d['id'])
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:8,代码来源:user.py

示例12: add_role

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def add_role(d):
     sql = ("INSERT INTO roles "
            "(name, description) "
            "VALUES (?,?);")
     vals = (d['name'], d['description'])
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:8,代码来源:user.py

示例13: get_roles

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def get_roles():
     sql = 'SELECT id, name AS value, description FROM roles;'
     return Dao.execute(sql)
开发者ID:joegillon,项目名称:allocat,代码行数:5,代码来源:user.py

示例14: change_password

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def change_password(user_id, new_password):
     sql = ("UPDATE users "
            "SET password=? "
            "WHERE id=?")
     vals = (User.__hash_pw(new_password), user_id)
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:8,代码来源:user.py

示例15: delete_user

# 需要导入模块: from models.dao import Dao [as 别名]
# 或者: from models.dao.Dao import execute [as 别名]
 def delete_user(user_id):
     sql = "DELETE FROM users WHERE id=?;"
     vals = (user_id,)
     return Dao.execute(sql, vals)
开发者ID:joegillon,项目名称:allocat,代码行数:6,代码来源:user.py


注:本文中的models.dao.Dao.execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。