MySQLW is a lightweight, high-performance C++ wrapper for MySQL, designed to simplify database interactions while maintaining efficiency and flexibility.
- Simple and clean API for MySQL operations
- High-performance query execution
- Secure parameterized queries
- Connection pooling for efficient resource management
- Lightweight and dependency-free
- Support for asynchronous operations (if applicable)
- MySQL client library (
libmysqlclient) - C++17 or later
- CMake (for building the project)
git clone https://github.com/fsystech/mysqlw.git
cd mysqlw
mkdir build && cd build
cmake ..
make
sudo make install#include "mysqlw.h"
int main() {
mysqlw::Connection conn("host", "user", "password", "database");
if (!conn.isConnected()) {
std::cerr << "Failed to connect to database" << std::endl;
return 1;
}
auto result = conn.query("SELECT * FROM users WHERE id = ?", 1);
for (auto& row : result) {
std::cout << "User ID: " << row["id"].as<int>() << "\n";
}
return 0;
}Connection(const std::string& host, const std::string& user, const std::string& password, const std::string& database)- Initializes the connection.bool isConnected() const- Checks if the connection is active.QueryResult query(const std::string& sql, Args... args)- Executes a query with optional parameters.
bool empty() const- Checks if the result set is empty.size_t size() const- Returns the number of rows.Row operator[](size_t index) const- Access a specific row.
Column operator[](const std::string& columnName) const- Access a specific column.template<typename T> T as() const- Convert the column value to the desired type.
This project is licensed under the MIT License.
Contributions are welcome! Feel free to submit issues or pull requests to improve MySQLW.
For any inquiries, reach out to FSys Tech Ltd.