How Do I Use RevDB With The Application Framework?
Using RevDB with a standalone application requires a couple of steps.
All of the Revolution database handlers are provided through an external named RevDB. The RevDB external relies on a database driver file for the type of database that you are connecting to. For example, if you are connecting to a SQLite database then you need the RevDB external and the dbsqlite database driver file.
Not only does RevDB need an external driver file it also needs to know where that driver file is located. This lesson will walk you through the process of including the necessary files and telling RevDB where the database driver files are located.
Add External and Database Driver Files to Your Application Folder
While working in the Revolution IDE the database external and drivers are available. When your application runs as a standalone you will need to include the external and database drivers. I like to copy to copy the necessary externals and driver files into my application's folder. I then add the files in the application's folder using the plugin. This allows me to move my application development folder around to different computers and know that I can always test the standalone.
You can locate the RevDB external and the database drivers in the Runtime folder (1) of your Revolution installation (2). There is a folder for each platform (3).
Copy the RevDB external and the database driver for the database that you are going to use to your application folder. In this example I have copied revdb.bundle/.dll and dbsqlite.bundle/.dll to my components/externals folder.
Add External To Application
Now it is time to tell the application framework about the files. Begin by adding the external using the plugin. Switch to the Stacks & Externals tab (1) and click the Add External button (2).
The dialog that appears has some pre-configured choices you can select from. RevDB is one of them. Select revDB (1) from the list and click Add (2).
Specify Location of External Files
revDB will appear in the list of the application's externals. Now you need to tell the application framework where to find the external file for each platform. Click on the OS X column.
A file selection dialog will appear. Select the revdb.bundle file from your application folder.
An icon will appear in the column (1). This means that the path to the external has been configured for OS X. Now click in the Win column (2).
Select the revdb.dll file from the application folder.
The Windows icon will appear in the Win column.
Add Driver as Standalone Resource
You have now finished adding the RevDB driver to the application. Now you need to add the database driver files.
Switch to the Standalone Resources tab (1) and click Add File (2) to add the database driver.
Select Driver File
Select the driver file. I'm selecting the dbsqlite.bundle file (1). Click Open (2).
Specify Relative Path
I selected dbsqlite.bundle which is the driver file for OS X. On OS X applications are distributed as bundles so the dbsqlite.bundle file should be placed inside of the application bundle when deployed. In order to do this you can use the [[APPLICATION]] variable in your relative path. This tells the GLX Application Framework that you want to place the file inside the bundle on OS X or in the root application directory on Windows.
Specify Platform For File
After specifying the path the file will appear in the list. The last step is to specify the platform that this file is used on. Click in the OS X column.
The OS X icon will appear in the column.
Repeat For Windows Driver
Repeat the same steps for the dbsqlite.dll file. Notice that I didn't use the [[APPLICATION]] variable in the path name since the file won't be used with OS X.
Tell RevDB Where To Find the Database Drivers
The last step is to tell the RevDB external where the database drivers files are located. You do this by calling revSetDatabaseDriverPath. A good place to do this is in the glxapp_initializeApplication handler located in the application stack script.
Copy & Paste
## Tell RevDB where the SQLite driver is
revSetDatabaseDriverPath glxapp_getProp("executable folder") & "/components/externals"