FlyingDB generates simple object files and simple query methods based on any SQLite database file. The files generated provide a preliminary set of classes and methods for interacting with a SQLite database. Although the data query methods are simple CRUD operations, hopefully, this will provide a code base to build upon and save time in the long run.
Currently, this tool handles all data in the database as String values. This tool retrieves data from the database and converts to a String type and also updates the database using a String type. Multiple data types may not be a huge issue due to SQLite's data type affinity feature if data is stored in the correct format (for example, only integers being stored in integer columns even though it's sent as a string to the database).
FlyingDB is released under the MIT License. See the license file for details.
FlyingDB is written as a Python script. flyingdb.py must be run in its home directory. To run and generate code, execute:
python flyingdb.py sqliteDBFile
To run and generate code with a prefix in front of class names for the simple objects, execute:
python flyingdb.py sqliteDBFile prefix
The python script generates Android Java code in the generated\android directory and iOS code in the generated\ios directory. The Android database helper class files are DatabaseAdapter.java and DatabaseHelper.java. The iOS database adapter class files are DatabaseAdapter.h and DatabaseAdapter.m.
An example of using the generated code can be found in the accompanying FlyingDBExample Eclipse project. To add to an existing project, create a new package called com.flyingboba.flyingdb and copy your files into it. The Android generated code will require some modifications depending on how you want to create your database (creating from code or embedding your DB file in the App and copying over to accessible phone storage).
If you do not want to copy an existing database over and want to generate the database in code, you can make the following modifications:
To generate your database by code, do it in the onCreate method of DatabaseHelper. Remove the methods related to copying the database over which include copyDatabase, checkDatabase, and createDatabase.
If you want to copy an existing database over, you can do so in the DatabaseAdapter.open() method by uncommenting and using the DatabaseHelper copyDatabase, checkDatabase, and createDatabase methods as shown in the FlyingDBExample code.
DatabaseAdapter.java - This file contains all the query methods for interacting with the database and utilizes the DatabaseHelper class.
DatabaseHelper.java - This file establishes a connection to the database and contains methods for copying an existing database over to phone storage.
See and try out the example iOS project (FlyingDBExampleIOS) for how you might use the generated code. The main code that calls the generated code can be found in ViewController.m. In ViewController.m, the code creates the database by calling on the DatabaseAdapter.copyOverDatabase() method which copies the database (assuming that you included the database in your project) to the App's document path. If you want to create the database in code, you can do so, but the database needs to be created in the App's document path for the other DatabaseAdapter query methods to work.