|
myTinySQL v0.2.0-2-g5000098
A tiny SQL interpreter over fixed-width text files
|
Turning statement results into console text or JSON for the browser page. More...
#include <string>#include <string_view>#include <vector>#include "Catalog.hpp"#include "Session.hpp"Go to the source code of this file.
Functions | |
| std::string | tinysql::renderText (const StatementResult &result) |
| Formats one result for the console. | |
| std::string | tinysql::renderJson (const std::vector< StatementResult > &results) |
Builds the JSON answer of POST /api/sql: one object per statement that has something to show. | |
| std::string | tinysql::renderTablesJson (const std::vector< TableSchema > &tables) |
Builds the JSON answer of GET /api/tables: every table with its columns. | |
Turning statement results into console text or JSON for the browser page.
Definition in file Output.hpp.
| std::string tinysql::renderJson | ( | const std::vector< StatementResult > & | results | ) |
Builds the JSON answer of POST /api/sql: one object per statement that has something to show.
Example: {"results":[{"sql":"DELETE FROM EMPLOY WHERE ID = 3","ok":true,"message":"1 row deleted from EMPLOY", "table":"EMPLOY"}]}. A SELECT or DESCRIBE also has "columns" (name, width in the data file, and whether the browser may edit the cell), "rows" (arrays of strings) and "idColumn" (index of the ID, or null).
| results | The results of a script, in order; silent ones (COLUMN, comments) are left out. |
Definition at line 95 of file Output.cpp.
| std::string tinysql::renderTablesJson | ( | const std::vector< TableSchema > & | tables | ) |
Builds the JSON answer of GET /api/tables: every table with its columns.
Example: {"tables":[{"name":"EMPLOY","readOnly":false,"autoId":true,"columns":[{"name":"ID","width":10},...]}]}. readOnly is true for SYSTEM_TABLE, which the page must not change.
| tables | The tables, from Catalog::tables(). |
Definition at line 131 of file Output.cpp.
| std::string tinysql::renderText | ( | const StatementResult & | result | ) |
Formats one result for the console.
| result | The result of one statement. |
Definition at line 67 of file Output.cpp.