Request database postman method (Omysql)

A, github address:

https://github.com/liyinchigithub/Omysql

Second, the effect of

 

Third, use

 


If you have installed computer configuration Git, node environment, you can press directly following
steps:

1, take the project from github pull

git clone [email protected]: liyinchigithub / Express-mysql-restfulAPI.git

2, switch to the directory

cd Omysql

3, the installation dependencies

npm install

4, start omysql service

node server.js

5, if your computer is not node environment, the specific configuration can refer to

The following two links:


windows https://jingyan.baidu.com/article/1876c8529c79e2890b1376dd.html

mac https://jingyan.baidu.com/article/6b1823098bdd9fba59e1597a.html

Build the following request postman above, you can achieve postman access the database!

Interface [API documentation]

1, create a database function

请求方法:POST
请求地址:
http://127.0.0.1:8004/mysql_demo/CreateDB/
请求 body:
{
"host":"127.0.0.1",
"user":"root",
"password":"12345678",
"port":"3306",
"query":"CREATE DATABASE Express_API_DB;"
}
响应 body:
{
"result": "success",
"status": 200
}

2、功能 创建表

请求方法:POST
请求地址:
http://127.0.0.1:8004/mysql_demo/CreateTable/
请求 body:
{
"host":"127.0.0.1",
"user":"root",
"password":"12345678",
"port":"3306",
"database":"数据库名称",
"query":"CREATE TABLE table4(name VARCHAR(100),id
VARCHAR(100),age INT,address VARCHAR(100),tel INT,PRIMARY
KEY ( id ))ENGINE=InnoDB DEFAULT CHARSET=utf8;"
}
响应 body:
{
"result": "success",
"status": 200
}

3、功能 插入数据

请求方法:PUT
请求地址:
http://127.0.0.1:8004/mysql_demo/insert_data/
请求 body:
{
"host":"127.0.0.1",
"user":"root",
"password":"12345678",
"port":"3306",
"database":"数据库名称",
"addSql":"INSERT INTO table4(address,age,id,name,tel)
VALUES('福建省泉州市丰泽区',19,225,'刘丽丽','159115');"
}

4、功能 更新数据

请求方法:PUT
请求地址:http://127.0.0.1:8004/mysql_demo/update/
请求 body:
{
"host":"127.0.0.1",
"user":"root",
"password":"12345678",
"port":"3306",
"database":"数据库名称",
"UpdateSql":"UPDATE table4 SET address='福建省厦门市
',age='17',id='123',name='赵柳',tel='123123' WHERE name='刘丽丽
';"
}

5、功能 删除表数据

请求方法:DELETE
请求地址:http://127.0.0.1:8004/mysql_demo/delete/
请求 body:
{
"host":"127.0.0.1",
"user":"root",
"password":"12345678",
"port":"3306",
"database":"数据库名称",
"delSql":"DELETE FROM table4 where name='王老五';"
}

6、功能 删除表

请求方法:DELETE
请求地址:http://127.0.0.1:8004/mysql_demo/drop
请求 body:
{
"host":"127.0.0.1",
"user":"root",
"password":"12345678",
"port":"3306",
"database":"数据库名称",
"DropSql":"DROP TABLE table4;"
}

7、功能 删除数据库

请求方法:DELETE
请求地址:http://127.0.0.1:8004/mysql_demo/drop
请求 body:
{
"host":"127.0.0.1",
"user":"root",
"password":"12345678",
"port":"3306",
"database":"数据库名称",
"DropSql":"DROP DATABASE Express_API_DB;"
}

8、功能 查询条件

请求方法:POST
请求地址:http://127.0.0.1:8004/mysql_demo/find
请求 body:
{
"host":"127.0.0.1",
"user":"root",
"password":"12345678",
"port":"3306",
"database":"数据库名称",
"findSql":"SELECT * FROM table4 WHERE name='赵柳';"
}

9、功能 查询表内所有数据

请求方法:POST
请求地址:http://127.0.0.1:8004/mysql_demo/find
请求 body:
{
"host":"127.0.0.1",
"user":"root",
"password":"12345678",
"port":"3306",
"database":"数据库名称",
"findSql":"SELECT * FROM table4;"
}

10、功能 查询所有数据库

请求方法:POST
请求地址:
http://127.0.0.1:8004/mysql_demo/show_databases
请求 body:
{
"host":"127.0.0.1",
"port":"3306",
"user":"root",
"password":"12345678",
"findSql":"show databases"
}

11、功能 查询数据库所有表

请求方法:POST
请求地址:
http://127.0.0.1:8004/mysql_demo/show_databases
请求 body:
{
"host":"127.0.0.1",
"port":"3306",
"user":"root",
"password":"12345678",
"database":"数据库名称",
"findSql":"show tables"
}


本文作者:李静怡

Guess you like

Origin www.cnblogs.com/longronglang/p/11324456.html