FSX / momoko

Wraps (asynchronous) Psycopg2 for Tornado.
http://momoko.61924.nl/
Other
363 stars 73 forks source link

add register_json #95

Closed cswingle closed 9 years ago

cswingle commented 9 years ago

Adds a register_json method to Connection and Pool classes.

I copied the register_hstore code, changing the unicode argument to loads for register_json and attempted to update the test and docs. I tested it with the code where I needed this function, and it was able to read json data from the database (9.3) and convert to a Python dict, exactly as I needed. I haven't tested it's ability to write JSON. In my experiments with psycopg2 it seemed like writing to the database required wrapping the Python object with psycopg2.extras.Json(dict), but I am probably missing something.

cswingle commented 9 years ago

I notice my pull request doesn't build with psycopg2ct because there is no register_json function for that library. According to the docs, it's unmaintained and suggests using psycopg2cffi, which does include register_json, and which works with my code changes. Is psycopg2ct support a requirement here?

haizaar commented 9 years ago

I've inherited psycopg2ct support, so I don't know why it was introduced originally. Frank, can you provide some information on the subject?

FSX commented 9 years ago

I think we can drop support for psycopg2ct if it isn't maintained anymore.

haizaar commented 9 years ago

Agreed. I've got rid of psycopg2ct in Travi CI.

@cswingle, Please rebase on master and create new your pull request - I want to make sure that Travis build passes.