def sqlInsert(def_buf, raw_a, raw_b):
        """ Reasonably portable SQL INSERT for from combined read buffer.
        Args:
            def_buf (SerialBlock): Database only serial block of all fields.
            raw_a (str): Raw A read as hex string.
            raw_b (str): Raw B read (if exists, otherwise empty) as hex string.

        Returns:
            str: SQL insert for passed read buffer
        """
        count = 0
        qry_str = "INSERT INTO  Meter_Reads ( \n\t"
        for fld in def_buf:
            if count > 0:
                qry_str += ", \n\t"
            qry_str = qry_str + fld
            count += 1
        qry_str += (",\n\t" + Field.Time_Stamp + ", \n\t" +
                    "Raw_A,\n\t" +
                    "Raw_B\n) \n" +
                    "VALUES( \n\t")
        count = 0
        for fld in def_buf:
            if count > 0:
                qry_str += ", \n\t"
            fld_type = def_buf[fld][MeterData.TypeValue]
            fld_str_content = def_buf[fld][MeterData.StringValue]
            delim = ""
            if (fld_type == FieldType.Hex) or \
                    (fld_type == FieldType.String) or \
                    (fld_type == FieldType.PowerFactor):
                delim = "'"
            qry_str = qry_str + delim + fld_str_content + delim
            count += 1
        time_val = int(time.time() * 1000)
        qry_str = (qry_str + ",\n\t" + str(time_val) + ",\n\t'" +
                   binascii.b2a_hex(raw_a) + "'" + ",\n\t'" +
                   binascii.b2a_hex(raw_b) + "'\n);")
        ekm_log(qry_str, 4)
        return qry_str
def sqlInsert(def_buf, raw_a, raw_b):
        """ Reasonably portable SQL INSERT for from combined read buffer.
        Args:
            def_buf (SerialBlock): Database only serial block of all fields.
            raw_a (str): Raw A read as hex string.
            raw_b (str): Raw B read (if exists, otherwise empty) as hex string.

        Returns:
            str: SQL insert for passed read buffer
        """
        count = 0
        qry_str = "INSERT INTO  Meter_Reads ( \n\t"
        for fld in def_buf:
            if count > 0:
                qry_str += ", \n\t"
            qry_str = qry_str + fld
            count += 1
        qry_str += (",\n\t" + Field.Time_Stamp + ", \n\t" +
                    "Raw_A,\n\t" +
                    "Raw_B\n) \n" +
                    "VALUES( \n\t")
        count = 0
        for fld in def_buf:
            if count > 0:
                qry_str += ", \n\t"
            fld_type = def_buf[fld][MeterData.TypeValue]
            fld_str_content = def_buf[fld][MeterData.StringValue]
            delim = ""
            if (fld_type == FieldType.Hex) or \
                    (fld_type == FieldType.String) or \
                    (fld_type == FieldType.PowerFactor):
                delim = "'"
            qry_str = qry_str + delim + fld_str_content + delim
            count += 1
        time_val = int(time.time() * 1000)
        qry_str = (qry_str + ",\n\t" + str(time_val) + ",\n\t'" +
                   binascii.b2a_hex(raw_a) + "'" + ",\n\t'" +
                   binascii.b2a_hex(raw_b) + "'\n);")
        ekm_log(qry_str, 4)
        return qry_str
def sqlInsert ( def_buf , raw_a , raw_b ) : count = 0 qry_str = "INSERT INTO  Meter_Reads ( \n\t" for fld in def_buf : if count > 0 : qry_str += ", \n\t" qry_str = qry_str + fld count += 1 qry_str += ( ",\n\t" + Field . Time_Stamp + ", \n\t" + "Raw_A,\n\t" + "Raw_B\n) \n" + "VALUES( \n\t" ) count = 0 for fld in def_buf : if count > 0 : qry_str += ", \n\t" fld_type = def_buf [ fld ] [ MeterData . TypeValue ] fld_str_content = def_buf [ fld ] [ MeterData . StringValue ] delim = "" if ( fld_type == FieldType . Hex ) or ( fld_type == FieldType . String ) or ( fld_type == FieldType . PowerFactor ) : delim = "'" qry_str = qry_str + delim + fld_str_content + delim count += 1 time_val = int ( time . time ( ) * 1000 ) qry_str = ( qry_str + ",\n\t" + str ( time_val ) + ",\n\t'" + binascii . b2a_hex ( raw_a ) + "'" + ",\n\t'" + binascii . b2a_hex ( raw_b ) + "'\n);" ) ekm_log ( qry_str , 4 ) return qry_str
Reasonably portable SQL INSERT for from combined read buffer.
        Args:
            def_buf (SerialBlock): Database only serial block of all fields.
            raw_a (str): Raw A read as hex string.
            raw_b (str): Raw B read (if exists, otherwise empty) as hex string.

        Returns:
            str: SQL insert for passed read buffer
Reasonably portable SQL INSERT for from combined read buffer . Args : def_buf ( SerialBlock ) : Database only serial block of all fields . raw_a ( str ) : Raw A read as hex string . raw_b ( str ) : Raw B read ( if exists otherwise empty ) as hex string .