Updating The Oahpa Database

Updating the database

The script install.py is used for updating the database. First, cd to the ped/oahpa directory and then test the script.

cd ped/oahpa/
python install.py -h

Changes in the database are visible in the interface straight away. Running the same installation script several times is not harmful. The same command that is used for installing the information can be used for updating.

Database Troubleshooting

Collocation errors

You might see an error like the following:

    DatabaseError at /hdn_oahpa/numra/
    (1267, "Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='")

Troubleshooting this might also be made more easy with a GUI utility such as: Sequel Pro, which is free.

Which typically means that the database hasn't been configured for utf-8. Use a preferred means of exploring the database to set three things, one is the database settings so that new tables will be created properly:

  1. 1. The database encoding must be "utf8" and the database collation must be "utf8_general_ci".

In SQL:

    ALTER DATABASE <DB_NAME> CHARACTER SET utf8 COLLATE utf8_unicode_ci;

And the next:

  1. 2. All database tables beginning with the language code (ex. hdn_drill_tags, hdn_drill_logs) must include these settings.

In SQL:

    ALTER TABLE `TABLE_NAME` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci ;

Note to replace the table name with the corresponding `hdn_`-prefixed table names.

For most of these tables, reinstalling the oahpa database as normal will be enough, but some tables (the log tables particularly) which are not re-created as part of the install process, so these must be manually altered.

If your preferred method of exploring the database is the mysql command line utility, see the

  1. 3. Database columns must also have the same collation.

Again the same note above applies: database tables that are re-created as part of install are easy to correct, but database tables that are not must be manually altered. See fix_collation.sql for ideas.