當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。