postman链接mysql执行操做

postman也能够链接mysqlnode

 

目录mysql

一、安装git

二、启动服务github

三、执行sql语句sql

 

一、安装数据库

想要postman链接mysql,须要安装xmysql,启动该服务,而后才能够调用。npm

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

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

 

安装xmsql:spa

 npm install -g xmysql

 

二、启动服务

启动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服务机器的信息

 

三、执行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

相关文章
相关标签/搜索