def fetchall(conn, sql):
'''查询所有数据'''
if sql is not None and sql != '':
cu = get_cursor(conn)
if SHOW_SQL:
print('执行sql:[{}]'.format(sql))
cu.execute(sql)
s='{:->8}'.format('ID')
print(s,end=' ')
s='{:->6}'.format('Match')
print(s,end=' ')
s='{:->4}'.format('Host')
print(s,end=' ')
s='{:->4}'.format('Watr')
print(s,end=' ')
s='{:-^14}'.format('STodd')
print(s,end=' ')
s='{:-^14}'.format('ENodd')
print(s)
r = cu.fetchall()
if len(r) > 0:
for e in range(len(r)):
listx=(list(r[e]))
#for i in range(len(listx)):
s='{:>8}'.format(listx[0])
print(s,end=' ')
s='{:>3}'.format(listx[1][0:3])
print(s,end=' ')
s='{:>2}'.format(listx[2][0:2])
print(s,end=' ')
s='{:>4}'.format(float(listx[3]))
print(s,end=' ')
s='{:>4}'.format(listx[4])
print(s,end=' ')
s='{:>4}'.format(listx[5])
print(s,end=' ')
s='{:>4}'.format(listx[6])
print(s,end='|')
s='{:>4}'.format(listx[7])
print(s,end=' ')
s='{:>4}'.format(listx[8])
print(s,end=' ')
s='{:>4}'.format(listx[9])
print(s,end=' ')
#if i==1:
# s='{:>5} '.format(listx[i])
# print(s)
else:
print('the [{}] is empty or equal None!'.format(sql))
database output
最新推荐文章于 2021-08-14 18:27:10 发布