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


Python dao.Dao类代码示例

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


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

示例1: edit_user_info

 def edit_user_info(self, user_name=None, password=None):
     """编辑用户信息"""
     if user_name:
         self.user_name = user_name
     if password:
         self.password = password
     return Dao.save_all()
开发者ID:Siglud,项目名称:ff,代码行数:7,代码来源:admin.py

示例2: add

 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,代码行数:7,代码来源:assignment.py

示例3: db_connect

 def db_connect(self):
     """返回一个数据库连接,跟上面的session不一样,想要裸写sql就调用这个。
     execute("把sql语句写进来就好了"),返回的结果需要注意,是ResultProxy。了解详细见下面连接
     http://docs.sqlalchemy.org/en/rel_1_0/core/connections.html?highlight=resultproxy#sqlalchemy.engine.ResultProxy。
     但是可以调用first(), all()等,差不多了一样用。只是返回的类似dict或mapping,先dict(res.items())比较好。
     """
     return Dao.db_connect()
开发者ID:ryanduan,项目名称:ktv-api,代码行数:7,代码来源:base_controller.py

示例4: login

 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,代码行数:9,代码来源:user.py

示例5: update

 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,代码行数:9,代码来源:assignment.py

示例6: update

 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,代码行数:9,代码来源:employee.py

示例7: setUp

 def setUp(self):
     """初始化数据库表结构, 完成数据库session,缓存及redis连接"""
     Dao.init_db_uri()
     self.session = Dao.session()
     Dao.init_table_schema()
     self.cache = OPCache()
     self.rds = Dao.redis()
     self.session.rollback()
开发者ID:ryanduan,项目名称:OnePiece,代码行数:8,代码来源:test_basic.py

示例8: get_for_timeframe

 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,代码行数:16,代码来源:assignment.py

示例9: get_for_project

 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,代码行数:17,代码来源:assignment.py

示例10: get_for_employee

 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,代码行数:19,代码来源:assignment.py

示例11: set_name

 def set_name(self, name):
     """修改名称"""
     if not name:
         return False
     self.district_name = name
     return Dao.save_all()
开发者ID:Siglud,项目名称:ff,代码行数:6,代码来源:district.py

示例12: delete

 def delete(self):
     """设置为删除"""
     self.is_delete = 1
     return Dao.save_all()
开发者ID:Siglud,项目名称:ff,代码行数:4,代码来源:district.py

示例13: recover

 def recover(self):
     """反删除"""
     self.is_delete = 0
     return Dao.save_all()
开发者ID:Siglud,项目名称:ff,代码行数:4,代码来源:district.py

示例14: Config

            login_url='/login/',
        )

        tornado.web.Application.__init__(self, urls, **settings)


if __name__ == '__main__':
    """"""
    options.define(name='config', default='dev')
    options.define(name='port', default=38001)
    options.define(name='process', default=1)
    options.define(name='server', default='total')

    tornado.options.parse_command_line()
    config = Config(options.config)
    Dao.init_db_uri(options.config)
    # TODO for dev and test
    Dao.init_schema()

    app = Application()
    app.config = options.config

    log.info('Starting box api server... Listening port: {}'.format(options.port))
    try:
        server = HTTPServer(app, xheaders=True)
        server.bind(int(options.port))
        server.start(num_processes=int(options.process))
        tornado.ioloop.IOLoop.instance().start()
    except Exception as e:
        log.error('box api can not running:\n{}'.format(e), exc_info=True)
        tornado.ioloop.IOLoop.instance().stop()
开发者ID:ryanduan,项目名称:ktv-api,代码行数:31,代码来源:ktv-api.py

示例15: edit_name

 def edit_name(self, name):
     """改名"""
     if name:
         self.category_name = name
     return Dao.save_all()
开发者ID:Siglud,项目名称:ff,代码行数:5,代码来源:category.py


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