generated from opensafely-core/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2363 from opensafely-core/evansd/extend-query-eng…
…ine-api Update QueryEngine API to support multiple results tables
- Loading branch information
Showing
27 changed files
with
747 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
Handles writing rows/tables to the console for local development and debugging. | ||
At present, this just uses the CSV writer but there's scope for using something a bit | ||
prettier and more readable here in future. | ||
""" | ||
|
||
import sys | ||
|
||
from ehrql.file_formats.csv import write_rows_csv_lines | ||
|
||
|
||
def write_rows_console(rows, column_specs): | ||
write_rows_csv_lines(sys.stdout, rows, column_specs) | ||
|
||
|
||
def write_tables_console(tables, table_specs): | ||
write_table_names = len(table_specs) > 1 | ||
first_table = True | ||
for rows, (table_name, column_specs) in zip(tables, table_specs.items()): | ||
if first_table: | ||
first_table = False | ||
else: | ||
# Add whitespace between tables | ||
sys.stdout.write("\n\n") | ||
if write_table_names: | ||
sys.stdout.write(f"{table_name}\n") | ||
write_rows_console(rows, column_specs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.