Rename the database in a BAM Mobile project

The BAM Mobile Project includes a SQLite database named mydatabase.db. Follow these steps to rename it.

  1. Create a BAM Mobile project.
    Select File > New > Genero BAM Mobile > BAM Mobile Project (.4pw). Provide a project name and location and click OK.
    A BAM Mobile Project is created. It includes a Project group that includes the following:
    • a Config library node containing the fglprofile file; and
    • a Database library node with two files: a database file (mydatabase.db) and a database meta-schema file (mydatabase.4dbx)
    It also includes a DatabaseMaintenance group containing a CreateDatabase application node, which contains the default database creation script mydatabase_sqt_x.4gl.

    The DBPATH environment variable is set for the project, specifying the location on disk where the default database file can be found: $(ProjectDir)\database;$(DBPATH)

  2. Rename the database and database meta-schema files to a name of your choosing.
    Under the database node, right-click on the file name and select Rename. Provide the new database name. Ensure you keep the proper file extension during the renaming process.
    Important: When renaming, use lower case letters.
    For example, to create a database named "test", rename the files test.db and test.4dbx.
  3. Update fglprofile (located in the config node) to reference your new database name.
    For our example, this involves replacing "mydatabase" with "test":
    dbi.default.driver = "dbmsqt"
    dbi.database.test.source = "test.db"
    Save your changes.
  4. In the database meta-schema file (.4dbx), use the context menu to model the database by adding tables and constraints and save your changes.
    You can skip this step to create an empty database.
  5. Generate the create database script.
    Right-click on the database meta-schema file name and select Generate Database Creation Script. At a minimum, select SQLite as the target database; select or de-select other options as desired.
  6. Save the generated script in the $(ProjectDir)/databaseMaintenance directory, and insert the file into the project in the CreateDatabase application node.
    At this time, you can also delete the mydatabase_sqt_x.4gl file, as it is no longer needed. To delete the file, right-click on the file name and select Delete from Disk. This option not only removes it from the project, but also removes it from the file system.
  7. Execute the CreateDatabase application.
    Right-click the CreateDatabase application node and select Execute.
    The database is created. The status of the operation displays in the Output view.
  8. Use DBExplorer to verify that the database was created properly.
    This step involves connecting to your new database and executing a query. For example, if you created a table named "account", you could enter the SQL statement:
    SELECT * FROM account;