https://github.com/mortinger91/header-only-cpp-mysql
Header-Only C++ Wrapper of Mysql Official Library
https://github.com/mortinger91/header-only-cpp-mysql
cpp cpp11 cpp14 cpp17 header-only mysql
Last synced: 2 months ago
JSON representation
Header-Only C++ Wrapper of Mysql Official Library
- Host: GitHub
- URL: https://github.com/mortinger91/header-only-cpp-mysql
- Owner: mortinger91
- Created: 2019-01-08T14:29:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-14T12:06:10.000Z (over 7 years ago)
- Last Synced: 2026-03-29T01:24:32.377Z (3 months ago)
- Topics: cpp, cpp11, cpp14, cpp17, header-only, mysql
- Language: C++
- Homepage:
- Size: 39.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# header-only-cpp-mysql
HEADER-ONLY easy C++ Mysql Wrapper
Only .h file, just paste it into your project
Following, a few more informations:
* build instructions
* how to find and install dependencies
* example function
* example cpp file
The official mysql C library is required and is the only dependency.
On Debian-like distributions issue the command "*sudo apt install libmysqlclient-dev*".
Try with "*sudo apt install default-libmysqlclient-dev*" as an alternative.
Look for an equivalent one if you are on a different OS or Linux distribution.
Using GCC build with **lmysqlclient** flag (tested on Debian buster/sid & GCC 8.2.0-13).
Example: "*g++ program main.o ... -lmysqlclient*".
If you cannot locate the package you are probably missing the mysql repositories.
Go to "*https://repo.mysql.com/*" and download the file "*mysql-apt-config_LATEST_VERSION_NUMBER_all.deb*".
You can download it using "*curl DOWNLOAD LINK --output pkg.deb*" or via browser.
Install it using "*sudo dpkg -i pkg.deb*" and choose your system version or the latest one.
After having added mysql repos you should be able to "*sudo apt install libmysqlclient-dev*".
**EXAMPLE:**
A very simple example.cpp file, that's everything you need to test the functions.
Compile it with "*g++ example example.cpp -lmysqlclient*"
Execute it with "*./example*"
*example.cpp:*
#include "mysql_wrapper.h"
int main(int argc, char *argv[])
{
example("my_hostname", "my_user", "my_password",
"SELECT * FROM myschema.mydatabase",
"INSERT INTO myschema.mydatabase (col1,col2,col3) VALUES (1,2,3)");
return 0;
}