【发布时间】:2020-07-11 05:01:19
【问题描述】:
所以我有一个包含人员表的数据库,并且人员具有特征 1-5。
我们用数据填充person表,我们最多可以添加5个特征,但这不是必需的
所以现在我想将每个人的特征写在一个列表中,但如果特征为空,则不会看到这些特征。 然后将结果打印出来给我。
我现在可以列出人员名单,但我仍然看到空值。
有人想通过 sql 或 python 排除空值吗?
编辑
#we fetch the result and then write it into the lists
SQLdeckung = 'Select * from Ergebnis_Compare
deckungCursor.execute(SQLdeckung)
result_update = deckungCursor.fetchall()
for i in result_update:
neueTabelleResult.append(i[0])
neueTabelleResult.append(i[1])
neueTabelleResult.append(i[2])
neueTabelleResult.append(i[3])
neueTabelleResult.append(i[4])
neueTabelleResult.append(i[5])
deckungCursor.execute(dropNeueTabelle)
except pysql.MySQLError as err:
print('Fehler in DeckungsCalc' , err)
connection.commit()
deckungCursor.close()
#here we want to print out the result
messagebox.showinfo('Dies ist die Deckungsliste:', neueTabelleResult)
【问题讨论】:
-
没有代码完全无法回答。你
commit()有变化吗? -
添加代码@roganjosh
-
为什么在附加到
neueTabelleResult之前不检查i[x]是否为空/空?