Reputation: 173
From the example:
>>> from htsql import HTSQL
>>> htsql = HTSQL("pgsql:///htsql_demo")
>>> rows = htsql.produce("/school{name, count(department)}")
How do I convert rows into JSON? Using the JSON formatter blows up:
>>> rows = htsql.produce("/school{name, count(department)}/:json")
UnsupportedActionError: unsupported action
While processing:
/school{name, count(department)}/:json
^^^^
I'm using HTSQL 2.3.3
Upvotes: 3
Views: 134
Reputation: 173
It has to be done via internal API:
from htsql import HTSQL
demo = HTSQL('pgsql:///htsql_demo')
rows = demo.produce('/school{name, count(department)}')
from htsql.core.fmt.emit import emit
with demo:
text = ''.join(emit('x-htsql/json', rows))
print text
The credit goes to Kirill Simonov, from the HTSQL user's group.
Upvotes: 3