Append presets from one darktable installation to another¶
I built the following script to migrate my presets from one darktable installation to another.
Script is "quick and dirty", but should work.
Please read the script main note for usage information.
Save the following script to file, name it append_presets.py and run it using python 2.7
"""Append presets from one darktable installation to another Before run: 1. backup! both db files. 2. Make sure darktable is not running 3. It is advised to copy the destination db to something like dest_library.db once append finished, you can switch between the newly modified file and the original one. Usage: python append_presets.py src.db dest.db ex: python append_presets.py .config/darktable/src_library.db .config/darktable/dest_library.db Both source and destination DBs must be an existing valid darktable DBs! Background: darktable store all presets in the ~/.config/darktable/library.db file. This is a sqlite3 database. Problems? yes! darktable store the pictures repository and much more data on the same DB. Which make it a bad idea to copy the DB between your laptop and desktop. (or just to copy your presets around) presets saved into the "presets" table with a unique id for each preset. (ID is based on preset name, operation and operation_id) two important columns are the op_params and the blendop_params. Both of type BLOB which make it harder to play with. Logic: open the source DB and copy all the presets to memory open destination DB and insert all presets from the source DB if insert succeed, commit the insert. else, this preset (probably) already exist in the destination Script works for me (appending my presets from darktable 1.2.3 on fedora to 1.4.1 on mint) But never tested in a professional way. Code is "quick and dirty" as I wrote it for a one time migration. No responsibilities assumed. 2014-04-16, email@example.com """ import sys import sqlite3 def getParameters(): numOfParms = len(sys.argv) srcDB = "src_library.db" destDB = "dest_library.db" if numOfParms > 1: srcDB = sys.argv if numOfParms == 3: destDB = sys.argv return srcDB, destDB def readDB (dbFile): conn = sqlite3.connect(dbFile) with conn: c = conn.cursor() c.execute("SELECT * FROM presets") rows = c.fetchall() return rows def appendAll(rows, destDB): conn = sqlite3.connect(destDB) sql = 'insert into presets values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);' c = conn.cursor() for row in rows: try: c.execute(sql,row) conn.commit() except: print "can't append:", row+"("+row+")" else: print row+"("+row+")", "Appended" def main(): srcDB, destDB = getParameters() rows = readDB(srcDB) appendAll(rows, destDB) main()