HyriseSQLParser/example/example.cpp

25 lines
646 B
C++
Raw Normal View History

2015-12-23 17:00:41 +01:00
// include the sql parser
#include "SQLParser.h"
int main(int argc, char *argv[]) {
if (argc <= 1) {
fprintf(stderr, "Usage: ./example \"SELECT * FROM test;\"\n");
return -1;
}
std::string query = argv[1];
2015-12-23 17:00:41 +01:00
// parse a given query
hsql::SQLStatementList* stmt_list = hsql::SQLParser::parseSQLString(query);
2015-12-23 17:00:41 +01:00
// check whether the parsing was successful
if (stmt_list->isValid) {
printf("Parsed successfully!\n");
printf("Number of statements: %lu\n", stmt_list->numStatements());
// process the statements...
} else {
printf("Invalid SQL!\n");
}
return 0;
}