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

  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值