diff --git a/NEWS.md b/NEWS.md index 6e587564..7d5d1669 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,10 @@ Red Panda C++ Version 1.0.5 - 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 - 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 - fix: hide function tips, when move or resize the main window diff --git a/windows/templates/mysql.template b/windows/templates/mysql.template new file mode 100644 index 00000000..fd2157f2 --- /dev/null +++ b/windows/templates/mysql.template @@ -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 diff --git a/windows/templates/mysql_c.txt b/windows/templates/mysql_c.txt new file mode 100644 index 00000000..a6fb3e1f --- /dev/null +++ b/windows/templates/mysql_c.txt @@ -0,0 +1,74 @@ +/* + A demo for mysql C API , from https://zetcode.com/db/mysqlc/ +*/ +#include +#include +#include + +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); +} \ No newline at end of file diff --git a/windows/templates/sqlite.template b/windows/templates/sqlite.template index 5b9f4bee..0d0aee7f 100644 --- a/windows/templates/sqlite.template +++ b/windows/templates/sqlite.template @@ -15,5 +15,5 @@ C=sqlite_c.txt UnitCount=1 Type=1 Compiler= -CppCompiler=-std=gnu++11 +CppCompiler= Linker=-lsqlite3