Initialize the MySQL and MariaDB database environment for future use.
LibraryName$ (optional) Filename (and path if needed) of the dynamic library to use. As most Linux distribution ship with packaged libmysql.so, it can be set to the correct name, so the libmaria.so doesn't have to be package with the executable. If this parameter is not specified, 'libmariadb.dll' (Windows), 'libmariadb.so' (Linux) or 'libmariadb.dylib' (OSX) will be used.
MySQL and MariaDB (an opensource fork of MySQL) are powerful, server based database managers which support very large database and high concurrency. PureBasic uses opensource MariaDB library to connect MySQL and MariaDB databases seemlessly, which can be used in commercial application without additional licenses. When shipping your PureBasic program, you will need to add 'libmariadb.dll' (Windows), 'libmariadb.so' (Linux) or 'libmariadb.dylib' (OSX) found in the 'PureBasic/Compilers' directory to your package.
There is no additional driver to install, all is ready to connect a MySQL or MariaDB server. For more information about MariaDB: https://mariadb.org/.
A MySQL or MariaDB database has to be connected using OpenDatabase() before using any other database functions. MySQL specific parameters have to be passed in the 'DatabaseName$' parameter of OpenDatabase():- host: Name of host or IP address to connect to. - port: Port number to connect to at the server host. - dbname: The database name.
UseMySQLDatabase() ; You should have a server running on localhost ; If OpenDatabase(0, "host=localhost port=3306 dbname=test", "user", "password") Debug "Connected to MySQL" Else Debug "Connection failed: "+DatabaseError() EndIf
OpenDatabase(), UseSQLiteDatabase(), UseODBCDatabase(), UsePostgreSQLDatabase()