MySQL數據庫的HTTP接口:MySQL HTTP API
此HTTP服務器提供了一個HTTP接口直接可以訪問到MySQL數據庫。允許客戶端通過Http來與MySQL數據庫交互。
Running/Installing
It's easy to run the HTTP server for this. Just clone the repo, install the dependencies and run the web server through bundler.
git clone https://github.com/adamcooke/mysql-api cd mysql-api bundle bundle exec rackup
Bare in mind that the server that you install this on will need to be able to access the databases which you connecting to.
Using the API
Once the server is running you can send requests to it containing server credentials and the queries you want to execute. You should send the queries to the/queryendpoint.
The body of your request should be JSON-formatted and the content type for the request must beapplication/json.
An example request looks like this:
{ "host":"localhost", "username":"root", "password":"supersecretpassword", "database":"mydatabase", "queries":[ { "name":"explain", "query":"EXPLAIN users;" }, { "name":"total_count", "query":"SELECT COUNT(id) AS count FROM users;" }, { "name":"records", "query":"SELECT * FROM users LIMIT 10;" }, { "name":"prepared_query", "query":"SELECT * FROM users WHERE username = ? AND first_name = ?;" "values":["adamcooke", "Adam"] } ] }
本文由用戶 pnxx 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!