base64 convert to binary by binascii is that right?

Frank Liou fk26541598fk at gmail.com
Fri Jul 11 09:06:07 CEST 2014


    conn = engine.connect()
    encoded = base64.b64encode(getbody)
    binary_string = binascii.a2b_base64(encoded)
    puresql = sqla.text("INSERT INTO friends(name) VALUES(:binary_string)")
    conn.execute(puresql,binary_string = binary_string)

first 

getbody trans to base64

then i convert to binary

is that right?

getbody is '123AAA!!中文'


this is my result 123AAA\357\274\201\357\274\201\344\270\255\346\226\207






More information about the Python-list mailing list