| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- #include "SingleConnection.h"
- #include "MySQLClient.h"
- #include <Logging.h>
- #include <sstream>
- namespace Test {
- bool SingleConnection()
- {
- Logging::Log(Logging::Severity::Info, "SingleConnection");
- try
- {
- std::string hostname1 = "MySQL";
- std::string username1 = "datalog";
- std::string password1 = "NfhdUwjjdRbslR";
- std::string database1 = "datalog";
- MySQL::MySQLClient MySQLClient1;
- MySQLClient1.Connect(hostname1, username1, password1, database1);
- if (!MySQLClient1.Connected())
- return false;
- std::stringstream query1;
- query1 << "SELECT * FROM `datalog` LIMIT 1;";
- auto result1 = MySQLClient1.ExecuteQuery(query1.str());
- if (result1.RowsCount() == 0)
- return false;
- result1.First();
- auto id1 = result1.Int("device_id");
- if (id1 == 0)
- return false;
- }
- catch (const std::exception& e)
- {
- std::stringstream ss;
- ss << "ERROR: " << e.what() << std::endl;
- Logging::Log(Logging::Severity::Error, ss.str());
- return false;
- }
- return true;
- }
- } // namespace Test
|