Chason Hayes wrote: > I am trying to convert raw binary data to data with escaped octets in > order to store it in a bytea field on postgresql server. I could do this > easily in c/c++ but I need to do it in python. I am not sure how to read > and evaluate the binary value of a byte in a long string when it is a non > printable ascii value in python. I read some ways to use unpack from the > struct module, but i really couldn't understand where that would help. I > looked at the MIMIEncode module but I don't know how to convert the object > to a string. Is there a module that will convert the data? It seems to me > that this question must have been answered a million times before but I > can't find anything. > > > > See http://www.postgresql.org/docs/8.1/interactive/datatype-binary.html > for a description of the problem domain. > > The URL you reference is discussing how you represent arbitrary values in string literals. If you already have the data in a Python string the best advise is to use a parameterized query - that way your Python DB API module will do the escaping for you!
regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC www.holdenweb.com PyCon TX 2006 www.python.org/pycon/ -- http://mail.python.org/mailman/listinfo/python-list