Skip to content

Commit

Permalink
Merge pull request #19 from alexcodreanu86/master
Browse files Browse the repository at this point in the history
Export dictionary results
  • Loading branch information
alculquicondor authored Apr 14, 2017
2 parents 0ded339 + 301d7d6 commit 8486c0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion psqlparse/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .parser import parse
from .parser import parse, parse_dict
10 changes: 6 additions & 4 deletions psqlparse/parser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ from .pg_query cimport (pg_query_parse, pg_query_free_parse_result,
PgQueryParseResult)


def parse(query):
def parse_dict(query):
cdef bytes encoded_query
cdef PgQueryParseResult result

Expand All @@ -20,7 +20,6 @@ def parse(query):
encoded_query = six.text_type(query).encode('utf8')

result = pg_query_parse(encoded_query)

if result.error:
error = PSqlParseError(result.error.message.decode('utf8'),
result.error.lineno, result.error.cursorpos)
Expand All @@ -29,6 +28,9 @@ def parse(query):

statement_dicts = json.loads(result.parse_tree.decode('utf8'),
strict=False)
statements = [build_from_obj(obj) for obj in statement_dicts]
pg_query_free_parse_result(result)
return statements
return statement_dicts


def parse(query):
return [build_from_obj(obj) for obj in parse_dict(query)]

0 comments on commit 8486c0f

Please sign in to comment.