skyformat99 / libmysqlnb Goto Github PK
View Code? Open in Web Editor NEWThis project forked from xtianbetz/libmysqlnb
library for using mysql in non-blocking applications
License: GNU General Public License v3.0
This project forked from xtianbetz/libmysqlnb
library for using mysql in non-blocking applications
License: GNU General Public License v3.0
MYSQL-NOBLOCK(1) MYSQL-NOBLOCK(1) NAME query_runner_init, query_runner_execute, query_runner_get_response_fd, query_runner_get_request_fd, query_runner_handle_all_results, query_runner_handle_next_result, query_runner_shutdown, SYNOPSIS #include "mysql-noblock.h" #define RUNNER_RESULT_EAGAIN -1 #define RUNNER_RESULT_SQL_ERROR 0 #define RUNNER_RESULT_ROWS 1 #define RUNNER_RESULT_NONE 2 query_runner *query_runner_init(char *hostname, char *user, char *password, char *database); void query_runner_execute(query_runner *runner, char *query, query_runner_callback callback, void *callback_data ); int query_runner_get_response_fd(query_runner *runner); int query_runner_get_request_fd(query_runner *runner); void query_runner_shutdown(query_runner * runner); int query_runner_handle_next_result(query_runner *runner); void query_runner_handle_all_results(query_runner *runner); typedef void (*query_runner_callback)(int, MYSQL_RES *, void *); DESCRIPTION A simple library for integrating MySQL into non-blocking, event-driven applications. All queries are submitted to a separate thread which sig‐ nals query completion by writing to a UNIX pipe. You can find out when the result is ready by using the file descriptor of the pipe in your own event loops using select(), poll(), etc. USAGE First write a callback for your query: void sql_results_callback(int result_code, MYSQL_RES *res, void *user_data) { if (result_code == RUNNER_RESULT_SQL_ERROR) { print("Query Failed!"); return; } /* Now do something with res (see mysql manual) */ } Next you will need to start the runner somewhere in your program: query_runner_init("myhost","username","password","database"); To integrate into your I/O event loop, you will need the runner's fd: int runner_response_fd = query_runner_get_response_fd(); To submit queries, use query_runner_execute(): query_runner_execute(runner, "SELECT foo FROM bar", sql_results_callback, my_data); When the query is complete, runner_response_fd will become ready for reading. DO NOT read directly from the fd, but instead use query_run‐ ner_handle_all_results() or query_runner_handle_next_result(). If there are no results ready these functions will do nothing. 23 January 10 MYSQL-NOBLOCK(1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.