13 unstable releases (3 breaking)

0.4.1 Aug 23, 2024
0.4.0 Jun 13, 2024
0.3.1 May 31, 2024
0.2.5 Jan 28, 2022
0.2.2 Mar 8, 2017

#1056 in Database interfaces

Download history 8255/week @ 2024-07-30 8934/week @ 2024-08-06 9380/week @ 2024-08-13 10478/week @ 2024-08-20 8497/week @ 2024-08-27 7938/week @ 2024-09-03 6711/week @ 2024-09-10 7647/week @ 2024-09-17 10351/week @ 2024-09-24 9609/week @ 2024-10-01 9137/week @ 2024-10-08 12356/week @ 2024-10-15 12331/week @ 2024-10-22 14180/week @ 2024-10-29 13691/week @ 2024-11-05 8811/week @ 2024-11-12

50,921 downloads per month
Used in 57 crates (2 directly)

MIT/Apache and maybe GPL-2.0

11MB
240K SLoC

C++ 115K SLoC // 0.2% comments Rust 102K SLoC // 0.0% comments C 20K SLoC // 0.2% comments Puppet 1K SLoC // 0.0% comments M4 534 SLoC // 0.4% comments Shell 272 SLoC // 0.2% comments Bitbake 196 SLoC // 0.0% comments Automake 130 SLoC // 0.1% comments AWK 106 SLoC // 0.0% comments GNU Style Assembly 92 SLoC // 0.2% comments LLVM 66 SLoC Visual Studio Project 45 SLoC Batch 10 SLoC Visual Studio Solution 6 SLoC Monkey C 1 SLoC

mysqlclient-sys

Autogenerated Rust bindings for libmysql-client (#include <mysql.h>)

Building

For this crate to build, libmysqlclient must be installed on your system (brew install mysql on macOS, apt-get install libmysqlclient-dev on Ubuntu, included with the server distribution on Windows). Additionally, either pkg-config or mysql_config must be present and able to successfully locate libmysqlclient.

The build script of the crate will attempt to find the lib path of libmysql-client using the following methods:

  • First, it will attempt to use pkg-config to locate it. All the config options, such as PKG_CONFIG_ALLOW_CROSS, PKG_CONFIG_ALL_STATIC etc., of the crate pkg-config apply.
  • MSVC ABI builds will then check for a Vcpkg installation using the vcpkg cargo build helper. Set the VCPKG_ROOT environment variable to point to your Vcpkg installation and run vcpkg install libmysql:x64-windows-static-md to install the required libraries. You need to set the MYSQLCLIENT_VERSION to specify the installed version in this case.
  • The library name mysqlclient is used unless MYSQLCLIENT_LIBNAME environment variable is specified.
  • If the library cannot be found by using the steps above the build script will check the MYSQLCLIENT_LIB_DIR and MYSQLCLIENT_VERSION environment variables.
  • If the library cannot be found using pkg-config, it will invoke the command mysql_config --variable=pkglibdir

The crate will try to use pregenerated bindings for a variety of libmysqlclient versions and supported operating systems.

The buildtime_bindgen feature allows you to generate bindings at build time matching your locally installed libmysqlclient version. It uses pkg-config, vcpkg, mysql_config or the MYSQLCLIENT_INCLUDE_DIR variable to determine the location of your mysql.h header. Additional bindgen configurations can be provided by setting the BINDGEN_EXTRA_CLANG_ARGS variable.

All MYSQLCLIENT_* environment can be post-fixed by a target to allow setting different values for different targets. For example MYSQLCLIENT_LIB_DIR_x86_64_unknown_linux_gnu would set the MYSQLCLIENT_LIB_DIR variable for the x86_64-unknown-linux-gnu target. The MYSQLCLIENT_LIB_DIR variable takes precedence before the target specific variants.

License

Licensed under either of

at your option.

The mysqlclient-src crate is licensed under GPL-2.0 to match the license of the packed mysql source code.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~0–5MB
~120K SLoC