import sqlite3 conn = sqlite3.connect('cms.db') c = conn.cursor() c.execute("SELECT id, title, cover_image FROM news_posts WHERE cover_image IS NOT NULL AND cover_image != '' LIMIT 20") for row in c.fetchall(): print(f'id={row[0]}: {row[2]}') conn.close()