Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74233 > unrolled thread

same code same tables but not the same result(use flask and postgres)

Started byFrank Liou <fk26541598fk@gmail.com>
First post2014-07-09 00:14 -0700
Last post2014-07-09 00:46 -0700
Articles 4 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  same code same tables but not the same result(use flask and postgres) Frank Liou <fk26541598fk@gmail.com> - 2014-07-09 00:14 -0700
    Re: same code same tables but not the same result(use flask and postgres) Chris Angelico <rosuav@gmail.com> - 2014-07-09 17:22 +1000
      Re: same code same tables but not the same result(use flask and postgres) Frank Liou <fk26541598fk@gmail.com> - 2014-07-09 00:25 -0700
        Re: same code same tables but not the same result(use flask and postgres) Frank Liou <fk26541598fk@gmail.com> - 2014-07-09 00:46 -0700

#74233 — same code same tables but not the same result(use flask and postgres)

FromFrank Liou <fk26541598fk@gmail.com>
Date2014-07-09 00:14 -0700
Subjectsame code same tables but not the same result(use flask and postgres)
Message-ID<a02846bc-5d64-47bb-8563-d3cbc5b82e33@googlegroups.com>
i use flask connect to postgres

def post_insert(username):
    conn = engine.connect()
    encoded = base64.b64encode(username.encode('utf-8'))
    puresql = sqla.text("INSERT INTO friends(name) VALUES(:encoded)")
    conn.execute(puresql,encoded = encoded)


i insert username encode with base64 to my database

but

one i got 

MTIzNDU2Nzg=   <==it's right

anoter i got

\x4d54497a4e4455324e7a673d

i change database to another database

but tables is use same code to create

what 's wrong??

[toc] | [next] | [standalone]


#74236

FromChris Angelico <rosuav@gmail.com>
Date2014-07-09 17:22 +1000
Message-ID<mailman.11677.1404890580.18130.python-list@python.org>
In reply to#74233
On Wed, Jul 9, 2014 at 5:14 PM, Frank Liou <fk26541598fk@gmail.com> wrote:
> one i got
>
> MTIzNDU2Nzg=   <==it's right
>
> anoter i got
>
> \x4d54497a4e4455324e7a673d

Encode that string as ASCII and represent the bytes in hexadecimal,
and you get the second one. My guess is that maybe you have one of
them running Python 2 and one running Python 3.

ChrisA

[toc] | [prev] | [next] | [standalone]


#74237

FromFrank Liou <fk26541598fk@gmail.com>
Date2014-07-09 00:25 -0700
Message-ID<f811ef8b-5f2d-4f98-8426-f2d5424ee4c8@googlegroups.com>
In reply to#74236
Hi ChrisA

i use same workspace

all the same python 3.3

[toc] | [prev] | [next] | [standalone]


#74239

FromFrank Liou <fk26541598fk@gmail.com>
Date2014-07-09 00:46 -0700
Message-ID<71a5e1d9-578f-47f6-a618-93ec50d36888@googlegroups.com>
In reply to#74237
oh by the way

one of database version is postgres 80420

another is 90304

80420 is fine

but 90304 is so strange

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web