Jam.py documentation

How to migrate to another databaseΒΆ

You can mirgate your data to another database.

For example, you developed your project with SQLite database amd want to move to Postgress.

To do this, follow these steps:

  1. Create an empty Postgress database

  2. Create a new project with this database

  3. Export the metadata of the SQLite project to a zip file in the Application Builder by clicking the Export button.

  4. Import the metadata to the new project. The web application with create database structures in the Postgress database.

  5. copy data from SQlite to Postgress database using the copy_database method of the task:

    • create in the sever module of the task the following function:

      from jam.db.db_modules import SQLITE
      
      def copy_db(task):
          task.copy_database(SQLITE, '/home/work/demo/demo.sqlite')
      
    • then you can execute it one of the following ways:

      • call this function in the on_created event handler:

        from jam.db.db_modules import SQLITE
        
        def copy_db(task):
            task.copy_database(SQLITE, '/home/work/demo/demo.sqlite')
        
        def on_created(task):
          copy_db(task)
        
      • create a button in some form and use the task server method to execute it

        function on_view_form_created(item) {
          item.add_view_button('Copy DB').click(function() {
            task.server('copy_db')
          });
        }
        
      • or run from from debbuging console of the browser:

        task.server('copy_db')
        
  6. Remove the code that was used.

Note

You can not migrate to SQLite database of the current database has foreign keys