I believe I'm having some trouble with data type conversions. Currently I have an encrypted string stored in a database where the database column is of type bytea. When I fetch the record, Python interprets the resulting data as:
Now, I'm pretty new to Python, but after some Googling it appears that I need to use the psycopg2 module's Binary function to convert it into something that Python can display. Converting it first to Binary gives me:
And then after converting that to a binary string, I get what appears to be an octal representation of the data:
What's bothering me here is the extra characters (i.e. the k, x, "^, f, etc.) My first guess is that things aren't being escaped correctly in the data type conversion?
Basically all I'm trying to do is get the encrypted field, convert it into an encrypted string, and then send that string to a decrypt method later on.
Any help or pushes in the right direction with this would be appreciated. Thanks.
Code:
(<read-only buffer for 0xXXXXXXXX, size 256, offset 0 at 0xXXXXXXXX>,)
Now, I'm pretty new to Python, but after some Googling it appears that I need to use the psycopg2 module's Binary function to convert it into something that Python can display. Converting it first to Binary gives me:
Code:
<psycopg2._psycopg.Binary object at 0xXXXXXXXX>
And then after converting that to a binary string, I get what appears to be an octal representation of the data:
Code:
\\315k\\261\\252\\023\\243\\215x\\369\\346\\376"^\\262f\\176\\000\\000\\000\\000\\000\\000 ...
What's bothering me here is the extra characters (i.e. the k, x, "^, f, etc.) My first guess is that things aren't being escaped correctly in the data type conversion?
Basically all I'm trying to do is get the encrypted field, convert it into an encrypted string, and then send that string to a decrypt method later on.
Any help or pushes in the right direction with this would be appreciated. Thanks.