This is for SQLite, so slightly different, but I had the same problem and I ended up writing this small Python script findnulls.py
to find all null values in a database:
import sqlite3
import sys
def main():
dbfile = sys.argv[1]
conn = sqlite3.connect(dbfile)
c = conn.cursor()
tables = c.execute("SELECT name FROM sqlite_master WHERE type='table';").fetchall()
for table in tables:
tablename = table[0]
cols = c.execute("PRAGMA table_info({0})".format(tablename)).fetchall()
for col in cols:
colname = col[1]
nullvals = c.execute("SELECT COUNT(*) FROM {0} WHERE {1} IS NULL;".format(tablename, colname)).fetchall()
if nullvals[0][0] != 0:
print("found {0} nulls in table: {1} column {2}".format(nullvals[0][0], tablename, colname))
main()
Where you would run it like this:
findnulls.py somedatabase.db
And the output looks like this:
found 1 nulls in table: Channels column MessageId
found 1 nulls in table: Channels column MessageChannel
found 1 nulls in table: Channels column SignalType
found 7 nulls in table: Channels column MinVal
found 7 nulls in table: Channels column MaxVal
found 9 nulls in table: Channels column AvgVal
found 9 nulls in table: Channels column Median
found 9 nulls in table: Channels column StdDev