-1

so, I read from DB binary field i.e. 'field1' to var Buf1, and then do something like:

unpack_from('I', Buf1, 0)

so, all is ok. but question is how can I ini Buf1 without going to DB? I can get value from DB manually and init my var statically, but how? in DB field 'field1' I see something like '0x7B0500000100000064000000B80100006'. and how can I init valid binary buffer from it?

ace
  • 249
  • 2
  • 7
  • Does 'DB' mean database? Why are you trying to initialize a database? Tables grow as needed when you add more records. Why is your hex number 33 digits (they're almost always even)? Are you trying to unpack a string into a number? – Nick T May 25 '10 at 20:02
  • DB - database. I mean that I don`t want to use database in test. I want to init binary buffer statically in code without going to database. so, I can go to database manually and copy value there, (example of value noted above, but really value is longer) but how to init buffer by that value? – ace May 26 '10 at 11:14

1 Answers1

0

Just use pack or pack_into it's the python's opposite of unpack_from.

See also that answer.

But you should elaborate on your question and give more sample code. The value you say you see from field is too large to read it into an integer. I wonder if you get the complete value.

Community
  • 1
  • 1
kriss
  • 23,497
  • 17
  • 97
  • 116