Giter Site home page Giter Site logo

lightmypy's Introduction

LightMyPy

A lightweight python class to manipulate MySQL database.

How to use

# config info, necessary parameters host, port, user, passwd, db
dbconfig = {'host':'127.0.0.1',
'port': 3306,
'user':'danfengcao',
'passwd':'123456',
'db':'test',
'charset':'utf8'}

db = LightMysql(dbconfig)

# use select() to select or show
sql_select = "SELECT * FROM Customer"
result_all = db.select(sql_select) # return all data
result_count = db.select(sql_select, 'count') # return number of lines
result_one = db.select(sql_select, 'one') # return one row

# use dml() to insert, update and delete
sql_update = "update Customer set Cost=2 where Id=2"
db.dml(sql_update)
sql_insert = "insert into Customer value(1,'abc')"
result_insert = db.dml(sql_insert)

# user query() to other operations
sql_query = "create table test0 (`ShowMapID` int(11))"
result_query = db.query(sql_query)

lightmypy's People

Contributors

danfengcao avatar michaelhe avatar

Watchers

James Cloos avatar  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.