> This is what I get in SQLAlchemy
>
>
> {'calculateTaxesByID': {('totalPriceEx()',): {}}, 'averageCost': {None:
> Decimal('7.4838709677419355')}, 'totalPriceEx': {None: Decimal('17.50')},
> 'getBasePriceEx': {None: Decimal('17.50')}}
>
> This is the result when I rand the following code in Postgresql
>
> "{'calculateTaxesByID': {('totalPriceEx()',): {}}}”
I’ve no experience running Python under postgresql directly but it looks very
much like the pickling in PG is not working correctly, as it is omitting a lot
of data. The use of Decimal objects is the only thing that stands out as
something that could change, if you’ve upgraded from very old psycopg2 versions
to recent ones. I can’t see how this has much to do with SQLAlchemy directly
however, obviously those extra keys are present in the data.
I’d debug this by looking at the data directly and sending it to a local
loads() function, comparing that to what this stored procedure is returning.
> As you can see I also added some older technique of depickle fall back code
> from sqlalchmey 0.4.8 with postgresql 8.4 the "decode" function but i had
> that fallback also here above in the SQLALchmey orm code: So I feel the code
> 2 paths are identical.
>
>
> def decode(data):
> diter = iter(data)
> output = []
> next = diter.next
> for x in diter:
> if x == "\\":
> try:
> y = next()
> except StopIteration:
> raise ValueError("incomplete backslash sequence")
> if y == "\\":
> pass
> elif y.isdigit():
> try:
> os = ''.join((y, next(), next()))
> except StopIteration:
> raise ValueError("incomplete backslash sequence")
> try:
> x = chr(int(os, base=8))
> except ValueError:
> raise ValueError("invalid bytea octal sequence
> {0}".format(os))
> else:
> raise ValueError("invalid backslash follow '{0}'".format(y))
> output.append(x)
> return ''.join(output)
>
>
> def co_un_pickle(value):
> try:
> if value is None:
> return None
> a = pickle.loads(value)
> return a
> except (EOFError, IndexError):
> try:
> a = pickle.loads(decode(value))
> return a
> except EOFError:
> return None
the above code has nothing to do with SQLAlchemy or psycopg2.
>
> My question for sqlalchmy or is this psycopg2 question?
it’s a Python pickle format question, or a “how does Python run under
Postgresql question”, from what I can see.
>
> is there any data manipulation that is happened before the pickle.loads
> function gets called? so is there any processing happening before
>
> def result_processor(self, value, dialect):
not really, but in any case, definitely work on getting round trips with
psycopg2 directly at the very least.
>
> I put a break point in the debugger and looked on the stack but didn't see
> anything getting done to the data at first quickly looking now.
>
> Which i could get some inside in this?
running Python in a PG stored procedure is a very advanced and esoteric
scenario, so if you are going there you need to be prepared to debug this down
to the byte level yourself :).
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.