def mkcon(s='my'): try: if s == 'my': mconn = connector.connect(**mconf) logger.info('Building connection to Mysql...') elif s == 'mic': mconn = connect(micfg) logger.info('Building connection to Micsql...') else: raise Exception('Bad config for make connection to SQL') cursor = mconn.cursor() except: logger.exception('Failure Information!') logger.info('CONN Failure!') return (cursor, mconn)
def pall(cursor): rows = cursor.fetchall() logger.debug('rows:' + str(len(rows))) for i in rows: logger.info(i) return rows
def pd(cursor, b=10): rows = cursor.fetchmany(b) logger.debug('rows:' + str(len(rows))) for i in rows: logger.info(i) return rows