# Path: dbtool/models.py
# class Dblist(models.Model):
#     """
#     asset modle
#         create_time = models.DateTime(default=datetime.now)
#     """
#     dbname=models.CharField(max_length=20, blank=True, null=True, verbose_name=u"DB_IP")
#     db_role = models.CharField(max_length=20, blank=True, null=True, verbose_name=u"db_role")
# 
# 
#     def __unicode__(self):
#         return self.dbname


import MySQLdb as mdb
import os
import ConfigParser
from dbtool.models import Dblist
from warnings import filterwarnings

# master_db_host="192.168.1.175"
# master_db_user="zzjr"
# master_db_password='zzjr#2015'
# master_db_name='zzjr_server'



#
# def exec_db(db_name,cmd):
#     res={'status':None,'mod_rows':None}
#     try:
#         con = mdb.connect(master_db_host, master_db_user, master_db_password, master_db_name, charset='utf8')
#         cur = con.cursor()
#         cur.execute(cmd)
#         cur.close()
#         mod_rows = cur.rowcount
#         print mod_rows
#         res.update({'status':'ok','mod_rows':mod_rows})
#         con.commit()
#         return res
#     except mdb.IntegrityError,e:
#         res.update({'status': e})
#         return res

# exec_db('zzjr_bank',cmd)



def db_list(db_role):

# Path: dbtool/models.py
# class Dblist(models.Model):
#     """
#     asset modle
#         create_time = models.DateTime(default=datetime.now)
#     """
#     dbname=models.CharField(max_length=20, blank=True, null=True, verbose_name=u"DB_IP")
#     db_role = models.CharField(max_length=20, blank=True, null=True, verbose_name=u"db_role")
# 
# 
#     def __unicode__(self):
#         return self.dbname


# Path: dbtool/dbtool_api.py
import MySQLdb as mdb
import os
import ConfigParser
from dbtool.models import Dblist
from warnings import filterwarnings


# master_db_host="192.168.1.175"
# master_db_user="zzjr"
# master_db_password='zzjr#2015'
# master_db_name='zzjr_server'



#
# def exec_db(db_name,cmd):
#     res={'status':None,'mod_rows':None}
#     try:
#         con = mdb.connect(master_db_host, master_db_user, master_db_password, master_db_name, charset='utf8')
#         cur = con.cursor()
#         cur.execute(cmd)
#         cur.close()
#         mod_rows = cur.rowcount
#         print mod_rows
#         res.update({'status':'ok','mod_rows':mod_rows})
#         con.commit()
#         return res
#     except mdb.IntegrityError,e:
#         res.update({'status': e})
#         return res

# exec_db('zzjr_bank',cmd)



def db_list(db_role):

    dblist=Dblist.objects.filter(db_role=db_role)