On Wed, 19 Aug 2026 22:33:27 -0800, Maria Sophia wrote:
# Prerequisite: "nova.db" SQL database file created using the
# last-known-good-version of the Tesla Coil Nova Launcher 7.0.57
# <https://mobile.softpedia.com/apk/nova-launcher/7.0.57/>
Why not provide your own commands for initializing a new database
if it doesn?t already exist? Save the user some work.
If you want to see an example of how it?s done, have look at the
?project-tags? script (yes, it?s a Python script) here <
https://gitlab.com/ldo/emacs-prefs>.
cursor.execute(
"SELECT DISTINCT screen FROM favorites WHERE container = -100 ORDER BY screen ASC;"
)
screens = cursor.fetchall()
You do this sequence of execute/fetch calls 4 times in your script. I
see you reuse the same cursor to save some extra setup work each time.
You can make things a little less fiddly with the help of this routine
(also to be found in the above script):
def db_iter(conn, cmd, mapfn = lambda x : x) :
"executes cmd on a new cursor from connection conn and yields the results in turn."
for item in conn.cursor().execute(cmd) :
yield mapfn(item)
#end for
#end db_iter
With this routine, the above sequence becomes
screens = list(db_iter \
(
conn,
"SELECT DISTINCT screen FROM favorites WHERE container = -100 ORDER BY screen ASC"
))
for (screen_num,) in screens:
or better still, put the lookup directly into the loop expression:
for screen_num in db_iter \
(
conn,
"SELECT DISTINCT screen FROM favorites WHERE container = -100 ORDER BY screen ASC",
mapfn = lambda x : x[0]
) :
cursor.execute(
"SELECT _id, title FROM favorites WHERE container = -100 AND screen = ?"
" AND intent IS NULL AND title IS NOT NULL AND TRIM(title) != '';",
(screen_num,),
)
folders = cursor.fetchall()
for folder_id, folder_name in folders:
Again, this can be simplified to
for folder_id, folder_name in db_iter \
(
conn,
"SELECT _id, title FROM favorites WHERE container = -100 AND screen = %d"
" AND intent IS NULL AND title IS NOT NULL AND TRIM(title) != '';"
%
screen_num
) :
and so on.
--- PyGate Linux v1.5.19
* Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)