backup

class camelot.core.backup.BackupMechanism(filename, storage=None, metadata=None)[source]

Create a backup of the current database to an sqlite database stored in a file.

The backupmechanism always considers the schema of the backed up database as the master, and never that of the backup. This means that when a backup is made, the backup file is first removed, and then filled with the tables from the the database to backup. When a restore is done, the schema of the database is not touched, but the tables are emptied and the data from the backup is copied into the existing schema.

backup(from_engine)[source]

Generator function that yields tuples : (numer_of_steps_completed, total_number_of_steps, description_of_current_step) while performing a backup.

Parameters:from_engine – a sqlalchemy.engine.Connectable object that provides a connection to the database to be backed up.
backup_table_filter(from_table)[source]

Method used to filter which tables should be backed up, overwrite this method for taking into account specific schema issues.

From_table:the table that is considered for backup
Returns:True when the table should be backed up
delete_table_data(to_table, to_connection)[source]

This method might be subclassed to turn off/on foreign key checks

classmethod get_default_storage()[source]
Returns:a camelot.core.files.storage.Storage object

Returns the storage to be used to store default backups.

By default, this will return a Storage that puts the backup files in the DataLocation as specified by the QDesktopServices

classmethod get_filename_prefix()[source]
Returns:a string with the prefix for the default name of the backup file

By default this method returns ‘backup’, overwrite this method to return a custom string, like the name of the company or such.

This method will be called inside the model thread.

prepare_schema_for_restore(from_connection, to_connection)[source]

This method will be called before the actual restore starts. It allows bringing the schema at the same revision as the backed up data.

restore(to_engine)[source]

Generator function that yields tuples : (numer_of_steps_completed, total_number_of_steps, description_of_current_step) while performing a restore.

Parameters:to_engine – a sqlalchemy.engine.Engine object that provides a connection to the database to be backed up.
restore_table_filter(from_table)[source]

Method used to filter which tables should be restored, overwrite this method for taking into account specific schema issues. restore_table_filter is different from backup_table_filter, since we might want to store data in the backup that should not be restored, like schema version information.

From_table:the table that is considered for backup
Returns:True when the table should be restored
update_schema_after_restore(from_connection, to_connection)[source]

This method will be called after the restore has been done. It allows bringing the schema at the revision the application expects.