Retrive data From a CSV using Python and insert into sql

def begin_import(request_type):
    print '[*] Begin import'
    csv_file = open(csv_file_name, "rb")
    table = csv.DictReader(csv_file)

    try:
        session = Session()
        session_row = FlurryAppMetric()
        for row in table:
            if request_type == "month":
                # Ignore time zone as the current table does not support it
                session_row.date = parse(row["dateTime"]).replace(tzinfo=None)
                session_row.api_key = row["app|apiKey"]
                session_row.country = row["country|iso"]
                session_row.active_users_month = row["activeDevices"]
               
            try:
                session.merge(session_row)
                session.commit()
            except SQLAlchemyError as e:
                print '[*] Failed to merge!' + str(e)
    except SQLAlchemyError as e:
        print '[*] SQLAlchemyError thrown: ' + str(e)
        session.rollback()
        session.close()
    finally:
        session.close()
        csv_file.close()

Truncate c# string

private static string TruncateString(string value, int maxLength)
{
   if (string.IsNullOrEmpty(value))
   {
     return value;
   }
 return value.Length <= maxLength ? value : value.Substring(0, maxLength);
}

Collect Unity Console logs - Used for Global exception catcher


Catch all the engine logs and send it to your native console or have a fancy Unity GUI console


Application.logMessageReceived += (output, stackTrace, logType) => {
            StringBuilder consoleLogs = new StringBuilder();
            consoleLogs.AppendLine("[*] Begin console log information");
            consoleLogs.AppendLine("LogMessage:" + output);
            consoleLogs.AppendLine("StackTrace:" + stackTrace);
            consoleLogs.AppendLine("LogType:" + logType.ToString());
            consoleLogs.AppendLine("[*] End console log information");
            Utils.SendLogsToConsole("Console Log", consoleLogs.ToString());
        };