postman连接mysql执行操作

postman也可以连接mysql

目录

1、安装

2、启动服务

3、执行sql语句

1、安装

想要postman连接mysql,需要安装xmysql,启动该服务,然后才可以调用。

预置条件:完成nodejs和npm的安装

安装时要注意版本的匹配问题,用法和注意事项可查看https://github.com/o1lab/xmysql#xmysql--one-command-to-generate-rest-apis-for-any-mysql-database

安装xmsql:

 npm install -g xmysql

2、启动服务

启动xmysql:

xmysql的相关启动参数,可以通过xmysql -h查看

xmysql -h host_name -u user_name -p user_password -d database_name -o port

备注:-h,-u,-p,-o:要连接的数据库的信息, -r,-n想要启动xmysql服务机器的信息

3、执行sql语句

启动xmysql后,即可通过http://localhost:3000/api/ 访问 xmysql 自动生成的 Rest API,详细的使用方法可通过https://github.com/o1lab/xmysql查看

备注:localhost是mysql服务要启动的机器的ip,3000是xmysql服务默认端口,可在启动时通过-r修改

case1:查询某表数据,get请求:http://localhost:3000/api/table_name:

case2:按某种条件查询,get请求:http://localhost:3000/api/table_name?_where=(username,eq,root)

case3:查询几行:get请求:http://localhost:3000/api/table_name?_fields=username,password,特殊的,分页_p=x&_size=x   

case4:插入数据,post请求:http://localhost:3000/api/table_name:

case5:新用patch、删除用delete

原文地址:https://www.cnblogs.com/weizhideweilai/p/10760286.html