Giter Site home page Giter Site logo

django_mysql_pool's Introduction

django_mysql_pool

Django mysql pool


这个是django中使用原生sql去操作数据库时,所建立的连接池helper
有四种类型可供选择
SS: SSCursor,            # 无缓存,返回元组类型,适合操作级别上万的sql
None: Cursor,            # 有缓存,返回元组类型,默认类型
Dict: DictCursor,        # 有缓存,返回带有字段的字典类型
SSDict: SSDictCursor     # 无缓存,返回带有字段的字典类型,适合操作级别上万的sql

怎么使用

1. 初始化 form dbHelper import Database
  dbpool = Database(cursorType=None) # 或以上几种缓存类型与返回值类型
2. sql增删改查
  dbpool.ExecQueryFirst("select * from user where id = 1")  # 只查询一条数据的情况
  dbpool.ExecQueryAll("select * from user")                 # 查询N条数据的情况
  dbpool.ExecNoQuery("")                                    # insert、 update、 delete都使用这个方法
  dbpool.ExecQueryYield("")                                 # 查询N条数据,但是需要把结果格式化为generator时使用的方法

django_mysql_pool's People

Contributors

heart-warming-li avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.