Skip to content

Refactor query execution into reusable core module#4

Closed
dbolser wants to merge 2 commits intomainfrom
codex/create-execute_query-function-and-refactor-code
Closed

Refactor query execution into reusable core module#4
dbolser wants to merge 2 commits intomainfrom
codex/create-execute_query-function-and-refactor-code

Conversation

@dbolser
Copy link
Copy Markdown
Owner

@dbolser dbolser commented Jul 8, 2025

Summary

  • introduce execute_query utility in new core module
  • refactor CLI and interactive shell to use the shared executor
  • add unit tests for the new helper and update existing tests

Testing

  • uv run pytest -q

https://chatgpt.com/codex/tasks/task_e_6864ed54821c83279d0d0854639887d0

cursor[bot]

This comment was marked as outdated.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: JSON Output Format Not Supported

The execute_query function does not support "json" output format. Although the CLI still accepts "json" as a valid option, passing it causes the function to fall through to the else block, resulting in incorrect tab-separated output instead of proper JSON. This is a regression, as the original code included explicit json.dumps() handling that was removed during refactoring.

pksql/core.py#L37-L51

pksql/pksql/core.py

Lines 37 to 51 in 1b90c4c

output_lines = []
if output_format == "table":
if is_query:
output_lines.append(str(result))
else:
output_lines.append("Query executed successfully.")
else:
delimiter = "," if output_format == "csv" else "\t"
if is_query:
header = delimiter.join(result.columns)
output_lines.append(header)
for row in result.fetchall():
output_lines.append(delimiter.join(map(str, row)))
else:
output_lines.append("Query executed successfully.")

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@dbolser dbolser closed this Jul 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant