MCPcopy Create free account
hub / github.com/activeloopai/deeplake / main

Function main

cpp/3rd_party/sql-parser/example/example.cpp:11–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#include "util/sqlhelper.h"
10
11int main(int argc, char* argv[]) {
12 if (argc <= 1) {
13 fprintf(stderr, "Usage: ./example \"SELECT * FROM test;\"\n");
14 return -1;
15 }
16 std::string query = argv[1];
17
18 // parse a given query
19 hsql::SQLParserResult result;
20 hsql::SQLParser::parse(query, &result);
21
22 // check whether the parsing was successful
23
24 if (result.isValid()) {
25 printf("Parsed successfully!\n");
26 printf("Number of statements: %lu\n", result.size());
27
28 for (auto i = 0u; i < result.size(); ++i) {
29 // Print a statement summary.
30 hsql::printStatementInfo(result.getStatement(i));
31 }
32 return 0;
33 } else {
34 fprintf(stderr, "Given string is not a valid SQL query.\n");
35 fprintf(stderr, "%s (L%d:%d)\n",
36 result.errorMsg(),
37 result.errorLine(),
38 result.errorColumn());
39 return -1;
40 }
41}

Callers 4

mkspans.cFile · 0.50
run_on_mainFunction · 0.50
callback_typeMethod · 0.50
thenMethod · 0.50

Calls 7

printStatementInfoFunction · 0.85
isValidMethod · 0.80
getStatementMethod · 0.80
errorMsgMethod · 0.80
errorLineMethod · 0.80
errorColumnMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected