• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dao.Dao类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: delete

 def delete(empid):
     sqls = [
         "DELETE FROM assignments WHERE employee_id=%s;" % (empid,),
         "DELETE FROM employees WHERE id=%s;" % (empid,)
     ]
     return Dao.transaction(sqls)
开发者ID:joegillon,项目名称:allocat,代码行数:6,代码来源:employee.py


示例17: get_all

 def get_all():
     sql = "SELECT * FROM employees ORDER BY name;"
     return Dao.execute(sql)
开发者ID:joegillon,项目名称:allocat,代码行数:3,代码来源:employee.py


示例18: op_session

 def op_session(self):
     """"""
     return Dao.session()
开发者ID:ryanduan,项目名称:OnePiece,代码行数:3,代码来源:base_controller.py


示例19: create_engine

from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor as sle

# from sqlalchemy import create_engine
#
# DB_URL = 'mysql://root:[email protected]/yiqidingtest?charset=utf8'
#
# conn = create_engine(DB_URL, encoding='utf8')

from models.fun_video import FunVideo
from models.dao import Dao

# from utils.utils import get_funtv_mp4
from utils.pinyin import pinyin

Dao.init_db_uri('rory')
db_session = Dao.db_session()


class FunMovieSpider(CrawlSpider):
    """
    风行视频爬取
    """

    name = 'fun_movie'
    allows_domains = ['fun.tv', ]
    start_urls = [
        'http://www.fun.tv/retrieve/c-e794b5e5bdb1.n-e5bdb1e78987.o-pl.pg-1'
    ]

    # http://www.fun.tv/vplay/g-118135.v-635102/
开发者ID:Roryjia,项目名称:funtv,代码行数:31,代码来源:funmovie_spiders.py


示例20: on_finish

 def on_finish(self):
     """关闭数据库连接"""
     Dao.close_mysql_session()
开发者ID:Siglud,项目名称:ff,代码行数:3,代码来源:base_handler.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python db.commit函数代码示例发布时间:2022-05-27
下一篇:
Python cursor.execute函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap