I want to know if there is an better way to check if a table of a given database is empty.
My version:
import sqlite3
con = sqlite3.connect('emails.db')
cur = con.cursor()
cur.execute("SELECT count(*) FROM (select 1 from my_table limit 1);")
print(cur.fetchall()[0][0])
con.close()
Output:
0 # If table `my_table' is empty
1 # If table 'my_table' is not empty