I came across several tutorials and packages for implementing the python JCON RPC server, for example:
They all do a good job in the sense that the server / application implementation is very simple: you just return the python object as a result, and the environment takes care of serializing it. However, this is not suitable for my needs, mainly because I look forward to serializing, possibly thousands of records from the database, and such a solution will require me to create one python object containing all the records and return as a result.
The ideal solution I'm looking for will include an infrastructure that will provide the application with a stream for recording the response and a JSON encoder that can encode an iterator (in this case, the cursor from pyobbc) on the fly, something like this:
def process(self, request, response):
cursor = self.conn.cursor()
cursor.execute(sql)
json.dump(response.getOut(), [cursor.description, cursor])
Can someone point me to a server structure that can provide me with a stream for writing and json serialization that can handle iterative like a pyobbc cursor and serialize it on the fly.
source
share