changes here and there
This commit is contained in:
57
main.cpp
57
main.cpp
@@ -8,34 +8,41 @@
|
||||
// drop table
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
Parser parser{};
|
||||
Executor executor{};
|
||||
usql::Parser parser{};
|
||||
usql::Executor executor{};
|
||||
|
||||
std::vector<std::string> sql_commands {
|
||||
"create table a (i integer not null, s varchar(64), f float null)",
|
||||
"insert into a (i, s) values(1, 'one')",
|
||||
"insert into a (i, s) values(2, 'two')",
|
||||
"insert into a (i, s) values(3, 'two')",
|
||||
"insert into a (i, s) values(4, 'four')",
|
||||
"insert into a (i, s) values(5, 'five')",
|
||||
"select i, s from a where i > 2",
|
||||
"select i, s from a where i = 1",
|
||||
"select i, s from a where s = 'two'",
|
||||
"select i, s from a where i <= 3 and s = 'one'",
|
||||
"select i, s from a where i > 0",
|
||||
"delete from a where i = 4",
|
||||
"select i, s from a where i > 0",
|
||||
"update a set f = 9.99 where i = 3",
|
||||
// "update a set s = 'three', f = 1.0 + 2.0 where i = 3",
|
||||
"select i, s, f from a where i = 3"
|
||||
// "select i, s from a where i > 0"
|
||||
};
|
||||
std::vector<std::string> sql_commands{
|
||||
"create table a (i integer not null, s varchar(64), f float null)",
|
||||
"insert into a (i, s) values(1, 'one')",
|
||||
"insert into a (i, s) values(2, 'two')",
|
||||
"insert into a (i, s) values(3, 'two')",
|
||||
"insert into a (i, s) values(4, 'four')",
|
||||
"insert into a (i, s) values(5, 'five')",
|
||||
"select i, s from a where i > 2",
|
||||
"select i, s from a where i = 1",
|
||||
"select i, s from a where s = 'two'",
|
||||
"select i, s from a where i <= 3 and s = 'one'",
|
||||
"select i, s from a where i > 0",
|
||||
"delete from a where i = 4",
|
||||
"select i, s from a where i > 0",
|
||||
"update a set f = 9.99 where i = 3",
|
||||
"select i, s, f from a where i = 3",
|
||||
"update a set s = 'three', f = f + 0.01 where i = 3",
|
||||
"select i, s, f from a where i = 3",
|
||||
"create table data (ticker varchar(8), price float null)",
|
||||
"load data from '/Users/vaclavt/Library/Mobile Documents/com~apple~CloudDocs/Development/usql/data.csv')",
|
||||
"select ticker, price from data"
|
||||
};
|
||||
|
||||
|
||||
for(auto command : sql_commands) {
|
||||
auto node = parser.parse(command);
|
||||
executor.execute(*node);
|
||||
}
|
||||
for (auto command : sql_commands) {
|
||||
std::cout << command << std::endl;
|
||||
auto node = parser.parse(command);
|
||||
auto result = executor.execute(*node);
|
||||
|
||||
result->print();
|
||||
// std::cout << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user