2014-07-18 3 views
3

를 사용하여 :어떻게 출력 JSON의 예에서 HTSQL의 파이썬 라이브러리

>>> from htsql import HTSQL 
>>> htsql = HTSQL("pgsql:///htsql_demo") 
>>> rows = htsql.produce("/school{name, count(department)}") 

가 어떻게 JSON에 행을 변환합니까? json으로 포매터를 사용하면 불면 :

>>> rows = htsql.produce("/school{name, count(department)}/:json") 
UnsupportedActionError: unsupported action 
While processing: 
    /school{name, count(department)}/:json 
             ^^^^ 

내가 뭔가를 가지고 2.3.3

답변

3

내부 API를 통해 수행 할 HTSQL 사용하고 있습니다 :

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 

크레딧은에서, 키릴 시모노로 이동을 HTSQL 사용자 그룹.