Database admin

Copy Database From Remote Machine to RPi mysqldump -h [source_db_server_ip_address] -u [source_db_username] -p[source_db_password] [source_db_database_name] | mysql -h localhost -u [dest_db_username] -p[dest_db_password] [dest_db_database_name] For example: mysqldump -h 1.2.3.4 -u admin1 -pabcd mydatabase | mysql -h localhost -u admin1 -pabcd mydatabase  

Read More

Parameterized (Prepared) Statement Type Codes

  MYSQL_TYPE_TINY C Variable: signed char SQL Type: TINYINT (-128 to 127) MYSQL_TYPE_SHORT C Variable: short int (int16_t) SQL Type: SMALLINT (-32768 to 32767) MYSQL_TYPE_LONG C Variable: int (int32_t) SQL Type: INT (-2147483648 to 2147483647) MYSQL_TYPE_LONGLONG C Variable: long long int (int64_t) SQL Type: BIGINT (-9223372036854775808 to 9223372036854775807) MYSQL_TYPE_FLOAT C Variable: float SQL Type: FLOAT […]

Read More

Errors

Discovering Error That Occured Use this line after something doesn't work to discover what the problem was std::cout << "Database error: " << mysql_errno(mysql1) << " – " << mysql_error(mysql1) << std::endl;  

Read More

Accessing The Database

Connecting Global Things #define DATABASE_NAME "YOUR_DATABASE_NAME" #define DATABASE_USERNAME "YOUR_DATABASE_USERNAME" #define DATABASE_PASSWORD "YOUR_DATABASE_PASSWORD" MYSQL *mysql1;   Connect and Disconnect #include <mysql/mysql.h> //***************************************** //***************************************** //********** CONNECT TO DATABASE ********** //***************************************** //***************************************** void mysql_connect (void) { //initialize MYSQL object for connections mysql1 = mysql_init(NULL); if(mysql1 == NULL) { fprintf(stderr, "%s\n", mysql_error(mysql1)); return; } //Connect to the database if(mysql_real_connect(mysql1, […]

Read More

Setup MySQL C Access

Some of this is based on the excellent guide here. Installing The MySQL C libraries MySQL comes with C-libraries: sudo apt-get update sudo apt-get upgrade sudo apt-get install libmysqlclient-dev Using In A Geany Project Include the library in your source files #include <mysql/mysql.h> Add these to the LIBS and CFLAGS sections of your makefile `mysql_config […]

Read More