, 2 min read
J-Pilot Plugin For SQLite Export
In SQL Datamodel For J-Pilot I described the SQLite datamodel. I wrote a J-Pilot plugin which can export the below entities and write them to an SQLite database file. The direction is one-way: from J-Pilot to SQLite.
- Various categories for above entities
Adding more entities is pretty easy. For example, if people need the Calendar Palm database exported, this can be implemented quickly. We use the usual SQLite API with
sqlite3_step(), and finally
The general mechanics of a J-Pilot plugin are described by Judd Montgomery, the author of J-Pilot, in this document. I took the
Expense/expense.c source code from the Expense plugin as a guide.
The plugin provides the following functionality:
- Create new database from scratch, it is called
- Export above mentioned entities
- In debug mode you can use J-Pilot's search to search in the SQLite database
If you call
jpilot -d then debug-mode is activated.
- Compile single source code file
- Copy library (
.sofile) in plugin directory (
- Copy datamodel SQL file
jptables.sqlinto plugin directory
Compilation is with below command:
gcc `pkg-config -cflags-only-I gtk+-2.0` -I <J-Pilot src dir> -s -fPIC -shared jpsqlite.c -o libjpsqlite.so -lsqlite3
For this to work you need the Pilot-Link header files and the J-Pilot (AUR) source code at hand.
Running the plugin: go to the plugins menu by main-menu selection or function key (F7 in my case), then press SQL button. All previous data is completey erased in the database, then all data is written to database within a single transaction.
In debug mode and in debug mode only, the "J-Pilot search" also searches through all entities in the SQLite database.
The long-term goal is that SQLite is the internal data structure for J-Pilot, thereby abandoning the binary files entirely.