#!/usr/bin/python
# -*- coding:utf-8 -*-
# Powered By KK Studio

import MySQLdb
import redis as PyRedis


# Wrapper MySQL
class DB:

    def __init__(self,host,port,user,passwd,db,charset="utf8"):
        self._conn = MySQLdb.connect(host=host, port=port, user=user, passwd=passwd, db=db, charset=charset)
        self._cur = self._conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)

    def close(self):
        self._cur.close()
        self._conn.close()

    def select(self,sql):
        self._cur.execute(sql)
        return self._cur.fetchall()

    def get(self,sql):
        self._cur.execute(sql)
        return self._cur.fetchone()

    def update(self,sql):
        pass

    def delete(self,sql):
        pass

    def insert(self,sql):
        pass

# Wrapper Redis
class Redis():

    def __init__(self,host,port=6379,db=0,password=''):
        self._host = host
        self._port = port
        self._db = db
        self._password = password

    def Connect(self):
        return PyRedis.Redis(self._host, self._port, self._db, self._password)
@@ -62,23 +62,8 @@
 io%0A%0A
-import MySQLdb%0A
 impo
@@ -86,83 +86,194 @@
 dis%0A
-%0A%0A# Wrapper MySQL%0Aclass DB:%0A%0A    def __init__(self,host,port,user
+from sqlalchemy import create_engine%0Afrom sqlalchemy.orm import sessionmaker, scoped_session%0A%0Aclass DB:%0A%0A    def __init__(self,host='localhost',port=3306,db='mysql',user='root'
 ,passwd
-,db
+=''
 ,cha
@@ -281,14 +281,15 @@
 set=
-%22utf8%22
+'utf-8'
 ):%0A 
@@ -299,100 +299,89 @@
     
-self._conn = MySQLdb.connect(host=host, port=port, user=
+db_uri = 'mysql+mysqldb://%25s:%25s@%25s:%25s/%25s?charset=%25s' %25 (
 user,
- 
 passwd
-=passwd, db=db, charset=
+,host,port,db,
 char
@@ -402,20 +402,23 @@
 elf.
-_cur
+session
  = self.
 _con
@@ -417,320 +417,257 @@
 elf.
-_conn.cursor(cursorclass=MySQLdb.cursors.DictCursor)%0A%0A    def close(self):%0A        self._cur.close()%0A        self._conn.close()%0A%0A    def select(self,sql):%0A        self._cur.execute(sql)%0A        return self._cur.fetchall()%0A%0A    def get(self,sql):%0A        self._cur.execute(sql)%0A        return self._cur.fetchone()
+create_session(db_uri,charset)%0A%0A%0A    def create_session(self,db_uri,encoding='utf-8'):%0A        engine = create_engine(db_uri, encoding=encoding, echo=False, pool_recycle=60)%0A        return scoped_session(sessionmaker(bind=engine, autocommit=False))%0A
 %0A%0A  
@@ -676,23 +676,18 @@
 def 
-updat
+clos
 e(self
-,sql
 ):%0A 
@@ -697,92 +697,58 @@
     
-pass%0A%0A    def delete(self,sql):%0A        pass%0A%0A    def insert(self,sql):%0A        pass
+if self.session:%0A            self.session.remove()
 %0A%0A# 

Improve DB Wrapper