Python Forum

Full Version: How to ignore empty columns from DB?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

As I read rows from a database and concatenate some columns into a string, some columns are empty.

What is the correct way to ignore those when building the string, and avoid having "None\n"?

for row in rows:
	#How to avoid eg. "Col3 stuff\nNone\nCol 5 stuff" ?
	bigstring = f'{row["col3"]}\n{row["col4"]}\n{row["col5"]}'
Thank you.
Have a look at this and see if it's what you need.
where name is not null