Last active
January 15, 2018 14:55
-
-
Save pajlada/a0499fa8676d6f65d29b52780b13f280 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto& db = DatabaseHandle::get(); | |
{ | |
hemirt::DB::Query<hemirt::DB::MariaDB::Values> q("SHOW TABLES LIKE \'wnmabot_settings\'"); | |
q.type = hemirt::DB::QueryType::RAWSQL; | |
auto res = db.executeQuery(std::move(q)); | |
if (auto eval = res.error(); eval) { | |
std::cerr << "Showing table `wnmabot_settings` error: " << eval->error() << std::endl; | |
this->err = true; | |
this->shutdown(); | |
return; | |
} | |
if (res.returned.empty()) { | |
// or maybe returned() assuming it ALWAYS returns a valid pointer if there's no error | |
// if (res.returned.empty()) { | |
q.setSql("CREATE TABLE `wnmabot_settings` (`setting` VARCHAR(32) UNIQUE NOT NULL, `value` VARCHAR(128) NOT NULL, PRIMARY KEY(`setting`))"); | |
q.type = hemirt::DB::QueryType::RAWSQL; | |
auto res2 = db.executeQuery(std::move(q)); | |
if (auto eval = res2.error(); eval) { | |
std::cerr << "Creating table `wnmabot_settings` error: " << eval->error() << std::endl; | |
this->err = true; | |
this->shutdown(); | |
return; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment