def save_migration(connection, basename):
    """ Save a migration in `migrations_applied` table """

    # Prepare query
    sql = "INSERT INTO migrations_applied (name, date) VALUES (%s, NOW())"

    # Run
    with connection.cursor() as cursor:
        cursor.execute(sql, (basename,))
        connection.commit()

    return True
Save a migration in `migrations_applied` table