MySQL Dual Connection (Embedded / Server) with QT5
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cmake
embdbtest
.gitignore
CMakeLists.txt
LICENSE
MySQLDualConnection.pro
README.md
embdriver.cpp
embdriver.h
main.cpp
mydbconn.cpp
mydbconn.h
remote_schema.sql

README.md

MySQL Dual Connection

MySQL Dual Connection is an example of how to achieve a dual (server & embedded) connection to MySQL/MariaDB in one Qt 5 application. The example creates a new Qt SQL driver (embeddedDriver) that can be used with the rest of Qt SQL classes.

Special requirement

  • Uses libmysqld.a (MySQL/MariaDB embedded library). It does not work with libmysqld.so because Qt 5 would not be able to determine which library to use “mysqlclient” (server libary) or “mysqld” at run time.
  • Requires a MySQL/MariaDB “share” directory that matches the library version. At this point the “share” directory inside the example database (embdbtest) matches MariaDB 10.0.19.

Parameters

  • a - Path to the embedded database.
  • d - Schema name.
  • r - Use remote connection. False by default.
  • H - MySQL/MariaDB host. Default is localhost.
  • P - MySQL/MariaDB port. Default is 3306.
  • u - MySQL/MariaDB user name.
  • p - MySQL/MariaDB user password.

Example of embedded connection

$ ./mysqldualconnection -a /path_to_my_embedded_database -d my_embedded_database

Example of server connection

$ ./mysqldualconnection -r -H my_MariaDB_server -u my_user_name -p my_password -d my_embedded_database

Technology

ODK Tools was built using:

  • C++, a general-purpose programming language.
  • Qt 5, a cross-platform application framework.
  • CMake, a cross-platform free and open-source software for managing the build process of software using a compiler-independent method.

Building and testing

To build this site for local viewing or development:

$ git clone https://github.com/qlands/mysqldualconnection.git
$ cd mysqldualconnection
$ mkdir build
$ cbuild
$ cmake ..
$ ./mysqldualconnection -a ../embdbtest -d embtest
>> Embedded connection
>> Code: 2 - Description: Row 2
>> Code: 1 - Description: Row 1

Author

Carlos Quiros (cquiros_at_qlands.com)

License

This repository contains the code of:

Otherwise, the contents of this application is GPL V3.