i'm trying for create a query with formatting in python, I can't figure out how i can string escape the binary input for data. It returns something like this:
INSERT INTO
python.UDP(Packet,Destination,Source,Protocol,Version,Header_Length,TTL,Protoco l_UDP,Target,Source_Port,Destination_Port,Length) VALUES (NULL, '00:0C:29:B2:14:0C', '192.168.178.50', '8 ', '4', '20', '128', '17', '192.168.178.24', '52371', '8888', '29227', 'b'Data\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 \x00\x00\x00\x00'');)
how can you properly escape the binary string value with formatting in python?
def setopUDP(destination, source, protocol, version, header_length, ttl, protocolEGP, target, source_port, destination_port, length, data):
query = ("INSERT INTO `python`.`UDP` (`Packet`, `Destination`, `Source`, `Protocol`, "
"`Version`, `Header_Length`, `TTL`, `Protocol_UDP`, `Target`, `Source_Port`, "
"`Destination_Port`, `Length`) VALUES (NULL, '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}', '{}');)"
.format(destination, source, protocol, version, header_length, ttl, protocolEGP, target, source_port, destination_port, length, data))
setopCON(query)