示例#1
0
def exeProcedure(sql):
    #try:
        filename='./config/dbinfo.ini'
        dblist=connectDb.getConnectInfo(filename)
        dbconn=connectDb.connectDb(dblist[0])
        cursor=connectDb.getCursor(dbconn)
        connectDb.executeSQL(cursor,sql)
        Res=connectDb.getSQLrst(cursor)
        connectDb.closeCursor(cursor)
        connectDb.closeConnect(dbconn)
        print Res
        return Res
示例#2
0
def getSqlData(sql):
    try:
        filename='./config/billdbinfo.ini'
        dblist=connectDb.getConnectInfo(filename)
        dbconn=connectDb.connectDb(dblist[0])
        cursor=connectDb.getCursor(dbconn)
        connectDb.executeSQL(cursor,sql)
        result=connectDb.getSQLrst(cursor)
        return result
    except Exception,e:
        getDataerr='%s %s' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),'execute getSqlData  falied')
        with open(r'./log/error.log','a') as error_log:
            print >> error_log,('%s %s' %(getDataerr,e))
示例#3
0
def executeCount(sql):
    try:
        filename='./config/dbinfo.ini'
        dblist=connectDb.getConnectInfo(filename)
        dbconn=connectDb.connectDb(dblist[0])
        cursor=connectDb.getCursor(dbconn)
        connectDb.executeSQL(cursor,sql)
        result=connectDb.getSQLrst(cursor)
        query_result=result[0][0]
        #print query_result,type(query_result)
        return query_result
    except Exception,e:
        count_err='%s %s' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),'executeCount  falied')
        with open(r'./log/error.log','a') as error_log:
            print >> error_log,('%s %s' %(count_err,e))
        return query_err
示例#4
0
def getSqlRes(sql):
    try:
        filename='./config/dbinfo.ini'
        dblist=connectDb.getConnectInfo(filename)
        dbconn=connectDb.connectDb(dblist[0])
        cursor=connectDb.getCursor(dbconn)
        connectDb.executeSQL(cursor,sql)
        cols=[]
        for col in cursor.description:
            cols.append(col[0])
        #print cols
        result=connectDb.getSQLrst(cursor)
        reslist=[]
        for res in result:
            reslist.append(list(res))
        return (cols,reslist)
    except Exception,e:
        getReserr='%s %s' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),'execute getSqlRes  falied')
        with open(r'./log/error.log','a') as error_log:
            print >> error_log,('%s %s' %(getReserr,e))
示例#5
0
def get_dbInfo(sql):
    try:
        filename='./config/dbinfo.ini'
        dblist=connectDb.getConnectInfo(filename)
        dbconn=connectDb.connectDb(dblist[0])
        cursor=connectDb.getCursor(dbconn)
        connectDb.executeSQL(cursor,sql)
        result=connectDb.getSQLrst(cursor)
        infodict={}
        for res in result:
            if infodict.has_key(res[0]):
                infodict[res[0]].append(res[1:])
            else:
                infodict[res[0]]=[res[1:]]
        #print infodict
        return infodict
    except Exception,e:
        geterr='%s %s' % (datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'),'execute get_dbInfo  falied')
        with open(r'./log/error.log','a') as error_log:
            print >> error_log,('%s %s' %(geterr,e))