- enhancement: add project template for libmysqlclient(libmariadbclient)

- enhancement: add libmysqlclient to the x86-64 version gcc in distribution
This commit is contained in:
Roy Qu 2022-04-22 11:25:30 +08:00
parent 0a1c2aea98
commit 2d6019bf23
4 changed files with 97 additions and 1 deletions

View File

@ -1,7 +1,10 @@
Red Panda C++ Version 1.0.5 Red Panda C++ Version 1.0.5
- enhancement: add autolink and project template for sqlite3 - enhancement: add autolink and project template for sqlite3
- enhancement: add sqlite3 lib to the gcc in distribution
- enhancement: improve the matching of function declaration and definitions - enhancement: improve the matching of function declaration and definitions
- fix: research button doesn't show find in files dialog - fix: research button doesn't show find in files dialog
- enhancement: add project template for libmysqlclient(libmariadbclient)
- enhancement: add libmysqlclient to the x86-64 version gcc in distribution
Red Panda C++ Version 1.0.4 Red Panda C++ Version 1.0.4
- fix: hide function tips, when move or resize the main window - fix: hide function tips, when move or resize the main window

View File

@ -0,0 +1,19 @@
[Template]
ver=2
Name=MySQL(MyriaDB)
Icon=mysql.ico
Description=A Sqlite3 API Example
Description[zh_CN]=MySQL数据库示例程序
Category=Utilities
Category[zh_CN]=工具
[Unit0]
CName=main.c
C=mysql_c.txt
[Project]
UnitCount=1
Type=1
Compiler=
CppCompiler=
Linker=-lmysqlclient -lws2_32 -ladvapi32 -lkernel32 -lshlwapi -lcrypt32 -lz -lsecur32

View File

@ -0,0 +1,74 @@
/*
A demo for mysql C API , from https://zetcode.com/db/mysqlc/
*/
#include <mysql/mysql.h>
#include <stdio.h>
#include <stdlib.h>
void finish_with_error(MYSQL *con)
{
fprintf(stderr, "%s\n", mysql_error(con));
mysql_close(con);
exit(1);
}
int main(int argc, char **argv)
{
MYSQL *con = mysql_init(NULL);
if (con == NULL)
{
fprintf(stderr, "%s\n", mysql_error(con));
exit(1);
}
if (mysql_real_connect(con, "localhost", "root", "",
"testdb", 0, NULL, 0) == NULL)
{
finish_with_error(con);
}
if (mysql_query(con, "DROP TABLE IF EXISTS cars")) {
finish_with_error(con);
}
if (mysql_query(con, "CREATE TABLE cars(id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(255), price INT)")) {
finish_with_error(con);
}
if (mysql_query(con, "INSERT INTO cars VALUES(1,'Audi',52642)")) {
finish_with_error(con);
}
if (mysql_query(con, "INSERT INTO cars VALUES(2,'Mercedes',57127)")) {
finish_with_error(con);
}
if (mysql_query(con, "INSERT INTO cars VALUES(3,'Skoda',9000)")) {
finish_with_error(con);
}
if (mysql_query(con, "INSERT INTO cars VALUES(4,'Volvo',29000)")) {
finish_with_error(con);
}
if (mysql_query(con, "INSERT INTO cars VALUES(5,'Bentley',350000)")) {
finish_with_error(con);
}
if (mysql_query(con, "INSERT INTO cars VALUES(6,'Citroen',21000)")) {
finish_with_error(con);
}
if (mysql_query(con, "INSERT INTO cars VALUES(7,'Hummer',41400)")) {
finish_with_error(con);
}
if (mysql_query(con, "INSERT INTO cars VALUES(8,'Volkswagen',21600)")) {
finish_with_error(con);
}
mysql_close(con);
exit(0);
}

View File

@ -15,5 +15,5 @@ C=sqlite_c.txt
UnitCount=1 UnitCount=1
Type=1 Type=1
Compiler= Compiler=
CppCompiler=-std=gnu++11 CppCompiler=
Linker=-lsqlite3 Linker=-lsqlite3