Exemple #1
0
def log_action(action, migration, status, when=None):
    if when == None:
        when = datetime.datetime.now()
    _execute_in_transaction("""
        INSERT INTO dmigrations_log(action, migration, status, datetime) 
        VALUES (%s, %s, %s, %s)
    """, [action, migration, status, when])
def log_action(action, migration, status, when=None):
    if when == None:
        when = datetime.datetime.now()
    statement = """
        INSERT INTO dmigrations_log(action, migration, status, datetime)
        VALUES (%s, %s, %s, %s)
    """
    params = [action, migration, status, when]
    # Should work fine in transaction for SQLite3, but gives
    # logic error or database not found error?!
    if settings.DATABASE_ENGINE == 'mysql':
        _execute_in_transaction(statement, params)
    elif settings.DATABASE_ENGINE == 'sqlite3':
        _execute(statement, params)
        cursor = connection.cursor()
        cursor.cursor.connection.commit()