drop table added
This commit is contained in:
16
main.cpp
16
main.cpp
@@ -3,15 +3,13 @@
|
||||
|
||||
// https://dev.to/joaoh82/what-would-sqlite-look-like-if-written-in-rust-part-1-2np4
|
||||
|
||||
// parser should get m_lexer as param and table executor to be able translate * or get types or so
|
||||
// podporovat create as select
|
||||
// drop table
|
||||
using namespace std::chrono;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
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, upper('one'))",
|
||||
"update table a set s = 'null string aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'",
|
||||
"update table a set s = 'null string aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'",
|
||||
// "update table a set i = null",
|
||||
"insert into a (i, s) values(2, 'two')",
|
||||
"insert into a (i, s) values(3, 'two')",
|
||||
@@ -36,19 +34,25 @@ int main(int argc, char *argv[]) {
|
||||
"select i, s, f from a where i < 300",
|
||||
"create table x as select i, s, f from a where i < 300",
|
||||
"select i, s, f from x where i < 300",
|
||||
"drop table x",
|
||||
"select i, s, f from a where i > 300",
|
||||
"select i, to_string(i, '%d.%m.%Y'), s, f from a where i > 300",
|
||||
"create table prices (datetime integer, symbol varchar(8), prev_close float, open float, price float, change float, change_prct varchar(16))",
|
||||
"load prices from '/Users/vaclavt/Library/Mobile Documents/com~apple~CloudDocs/Development/usql/prices.csv'",
|
||||
"insert into prices (datetime, symbol, prev_close, open, price, change, change_prct) values (1626979443, 'MPC', 54.08, 53.82, 53.63, -0.832101, '-0.83 %')",
|
||||
"select to_string(datetime, '%d.%m.%Y %H:%M:%S'), symbol, prev_close, open, price, change, change_prct from prices"
|
||||
"select to_string(datetime, '%d.%m.%Y %H:%M:%S'), symbol, prev_close, open, price, change, change_prct from prices where symbol = 'SYF'"
|
||||
};
|
||||
|
||||
|
||||
usql::USql uSql{};
|
||||
|
||||
for (auto command : sql_commands) {
|
||||
std::cout << command << std::endl;
|
||||
time_point<high_resolution_clock> start_time = high_resolution_clock::now();
|
||||
auto result = uSql.execute(command);
|
||||
time_point<high_resolution_clock> end_time = high_resolution_clock::now();
|
||||
|
||||
std::cout << command << std::endl;
|
||||
std::cout << "run time: " << duration_cast<milliseconds>(end_time - start_time).count() << " ms " << std::endl;
|
||||
|
||||
result->print();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user