当前位置: 首页 > news >正文

windows搭建网站开发/推广游戏怎么拉人最快

windows搭建网站开发,推广游戏怎么拉人最快,多语种网站建设,南宁网红打卡地有哪些地方GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源。 导语 有时候用 Postman 接口测试需要获取MySQL的查询结果做接口输出的校验,这里介绍下 Postman 通过 Restful API 接口访问 MySQL 的工具xmysql的使用方法。 步骤 一、使用nmp…
  • GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源。

导语

有时候用 Postman 接口测试需要获取MySQL的查询结果做接口输出的校验,这里介绍下 Postman 通过 Restful API 接口访问 MySQL 的工具xmysql的使用方法。

步骤

一、使用nmp安装xmysql

注:npm的安装和配置自行百度,这里主要讲xmysql,就不赘述了

C:\Users\wmp>node -v
v12.16.3
C:\Users\wmp>
C:\Users\wmp> npm install -g xmysql
C:\Users\wmp\AppData\Roaming\npm\xmysql -> C:\Users\wmp\AppData\Roaming\npm\node_modules\xmysql\bin\index.js> es5-ext@0.10.59 postinstall C:\Users\wmp\AppData\Roaming\npm\node_modules\xmysql\node_modules\es5-ext
> node -e "try{require('./_postinstall')}catch(e){}"+ xmysql@0.5.1
added 131 packages from 68 contributors in 22.806s

安装完输入xmysql可以查看具体参数,同时也表示安装成功

C:\Users\wmp>xmysql
Usage: index [options]Options:-V, --version            output the version number-h, --host <n>           hostname of database / localhost by default-u, --user <n>           username of database / root by default-p, --password <n>       password of database / empty by default-d, --database <n>       database schema name-r, --ipAddress <n>      IP interface of your server / localhost by default-n, --portNumber <n>     port number for app / 3000 by default-o, --port <n>           port number for mysql / 3306 by default-S, --socketPath <n>     unix socket path / not used by default-s, --storageFolder <n>  storage folder / current working dir by default / available only with local-i, --ignoreTables <n>   comma separated table names to ignore-a, --apiPrefix <n>      api url prefix / "/api/" by default-y, --readOnly           readonly apis / false by default-c, --useCpuCores <n>    use number of CPU cores (using cluster) / 1 by default-h, --help               output usage informationExamples:$ xmysql -u username -p password -d databaseSchemaError: password for database is missing
Error: database name is missingC:\Users\wmp>

连接数据库: xmysql -h host_name -o port -u user_name -p user_password -d database_name

C:\Users\wmp>xmysql -h 192.168.5.103 -u root -p 123456 -o 3301 -d testGenerating REST APIs at the speed of your thought..- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Database              :    testNumber of Tables      :    3   【test库表的数量】REST APIs Generated   :    62  【生成的api数量】Xmysql took           :    0 secondsAPI's base URL        :    localhost:3000   【api的访问方式,端口3000可以通过参数 -n进行修改为其他】- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

xmysql的默认端口是3000,下面用postman调用api的方式试下数据库的增删改查(注: 在postman中执行sql语句时,cmd窗口和msqll都不可以关闭)

API Overview

HTTP TypeAPI URLComments
GET/获取所有 REST API
GET/api/tableName列出表的行
POST/api/tableName创建一个新行
PUT/api/tableName用新行替换现有行
POST/api/tableName/bulk创建多行 - 在请求正文中发送对象数组
GET/api/tableName/bulk列出多行 - /api/tableName/bulk?_ids=1,2,3
DELETE/api/tableName/bulk删除多行 - /api/tableName/bulk?_ids=1,2,3
GET/api/tableName/:id按主键检索一行
PATCH/api/tableName/:id按主键更新行元素
DELETE/api/tableName/:id按主键删除一行
GET/api/tableName/findOne作为列表工作,但获得单个记录匹配条件
GET/api/tableName/count计算表中的行数
GET/api/tableName/distinct表中的不同行 - /api/tableName/distinct?_fields=col1
GET/api/tableName/:id/exists是否存在行
GET/api/parentTable/:id/childTable获取具有父表外键的子表行列表
GET/api/tableName/aggregate汇总数字列的结果
GET/api/tableName/groupby按列的结果分组
GET/api/tableName/ugroupby使用一次调用按结果进行多个分组
GET/api/tableName/chart基于 (min,max,step) 或 (step array) 或 (automagic) 的数值列分布
GET/api/tableName/autochart与 Chart 相同,但会自动识别哪些是数字列
GET/api/xjoin处理连接
GET/dynamic使用参数执行动态 mysql 语句
GET/upload上传单个文件
GET/uploads上传多个文件
GET/download下载文件
GET/api/tableName/describe描述每个表的列
GET/api/tables获取数据库中的所有表
GET/_health获取进程和 mysql 的运行状况
GET/_version获取 Xmysql、mysql、node 的版本

查看对象表下所有可用的接口,可以参数调用并查看结果

http://localhost:3000/

以下是t1表可用的接口:

file

file

用t1表做一个简单的查询测试:

file

1、查询t1的整表数据

GET /api/t1
SQL: select  *  from `t1` ;

file

2、带条件查询

GET /api/t1?_where=(ida,eq,1)
SQL: select  *  from `t1`  where `ida`=1;

file

3、分页查询

file

4、in查询

GET /api/t1/bulk?_ids=1,2,3
SQL: select  *  from `t1`  where `ida` in (1,2,3)  limit 0,20;

file

其他的增删改参考上述的API Overview,下面演示下xmysql在postman接口测试中的应用:

应用一:接口测试数据校验

  1. 启动xmysql服务:(测试时保持服务启动状态不要关闭)
xmysql -h 192.168.5.103 -u root -p Great@123 -o 3306 -d SCOTT

file

  1. 创建postman测试collection,包含测试接口和xmysql获取mysql数据接口
#测试接口1:获取全国行政区划
http://127.0.0.1:8369/query?fid={{pregion_code}}
#接口2:xmysql获取mysql数据接口
http://localhost:3000/api/AREAS?_where=(parent_region_code,eq,{{pregion_code}})

接口参数化,可在postman collection中设置全局参数并赋值

//定义变量做接口的输入传参并设置为全局变量
var pregion_code=110100;
pm.environment.set("pregion_code", pregion_code);

file

接口输出参数化设置:

在接口1Tests中用js脚本对接口输出结果需要断言的部分转参数并设置环境变量,以便在接口2的数据库输出中进行比较

//返回body转json
var jsonData = JSON.parse(responseBody);
var list=jsonData.result;
var regionCode=[];num=list.length;for (let i=0;i<num;i++){regionCode.push(list[i].id);}
//设置为全局变量,用于数据库查询接口的数据校验
pm.environment.set("regionCode", regionCode);//console.log(regionCode)

file

接口2Tests中用js脚本对数据库查询到的json脚本进行处理,获取需要的数据,参数化后与接口1的输出进行比较

//返回body转json
var jsonData = JSON.parse(responseBody);
var res_id=[];
num=jsonData.length;//获取数据库查询结果的region_code列
for (let i=0;i<num;i++){res_id.push(jsonData[i].region_code+'');}//获取接口1输出的结果参数regionCode
var regionCode=pm.environment.get("regionCode");//断言 比较接口和数据库的输出结果
tests["接口断言成功!!"] = res_id.sort().toString === regionCode.sort().toString ; //console.log(res_id);

file

  1. 运行测试collection

file

应用二:利用postman+xmysql实现MySQL快速生成大量测试数据

建表脚本

drop table if exists t1;CREATE TABLE  t1
(
id int NOT NULL AUTO_INCREMENT PRIMARY KEY comment '用户ID', 
person_name varchar(30) comment '用户名称') 

这里演示插入10000条:

  1. 创建insert 接口

file

file

  1. 设置collection并执行

file

3、执行完毕,查看表数量

file

调用表行数查询接口查询结果:

file

file

声明:xmysql工具主要用于测试环境,结合接口测试等,主要用于内部测试,在生产还是不建议使用,因为这款工具会造成严重的数据安全问题。

参考文档:

https://gitee.com/thinkyoung/xmysql

Enjoy GreatSQL :)

文章推荐:

面向金融级应用的GreatSQL正式开源 https://mp.weixin.qq.com/s/cI_wPKQJuXItVWpOx_yNTg

Changes in GreatSQL 8.0.25 (2021-8-18) https://mp.weixin.qq.com/s/qcn0lmsMoLtaGO9hbpnhVg

MGR及GreatSQL资源汇总 https://mp.weixin.qq.com/s/qXMct_pOVN5FGoLsXSD0MA

GreatSQL MGR FAQ https://mp.weixin.qq.com/s/J6wkUpGXw3YkyEUJXiZ9xA

在Linux下源码编译安装GreatSQL/MySQL https://mp.weixin.qq.com/s/WZZOWKqSaGSy-mpD2GdNcA

关于 GreatSQL

GreatSQL是由万里数据库维护的MySQL分支,专注于提升MGR可靠性及性能,支持InnoDB并行查询特性,是适用于金融级应用的MySQL分支版本。

Gitee:

https://gitee.com/GreatSQL/GreatSQL

GitHub:

https://github.com/GreatSQL/GreatSQL

Bilibili:

https://space.bilibili.com/1363850082/video

微信&QQ群:

可搜索添加GreatSQL社区助手微信好友,发送验证信息“加群”加入GreatSQL/MGR交流微信群

QQ群:533341697

微信小助手:wanlidbc

本文由博客一文多发平台 OpenWrite 发布!

http://www.jmfq.cn/news/4728817.html

相关文章:

  • 做网站java好还是.net好/网络推广经验
  • 河南省城乡和住房建设厅网站/福州关键词快速排名
  • 莱芜市莱城区城乡建设局网站/百度视频下载
  • 如何做快递api接口网站/外贸seo网站建设
  • wordpress缩略图采集火车头/重庆seo优
  • 世界建筑网站/网络搜索关键词排名
  • 网站建设网站定制开发/seo推广方案
  • 杭州企业公司网页设计/池州网站seo
  • 网站策划建站/百度商城
  • 建设网站 费用/外贸营销网站怎么建站
  • 专业做化妆品外包材的招聘网站/seo实战优化
  • 工商工事上哪个网站做/淘宝指数
  • 网站开发常用语言比较/聚合搜索引擎
  • 网站制作常见问题 图片版权/搜索引擎营销的优缺点
  • 福州专业网站设计/网络广告策划书模板范文
  • 提供温州手机网站制作哪家好/惠州seo关键词排名
  • 苏州住房和城乡建设厅网站/会计培训班哪个机构比较好
  • 新的网站设计制作/seo基础教程
  • 四川 法治政府建设 网站/seo优化自动点击软件
  • 哪些网站不扣流量/小吃培训去哪里学最好
  • 荔湾区pc端网站建设/西安疫情最新数据
  • 用户登录/网络优化工程师需要学什么
  • 网站网站建设专业/广西seo
  • 昆明医院网站建设/如何做好口碑营销
  • php网站开发公司/怎么制作网页教程
  • wordpress 全站通知/网站推广软件下载
  • 企业的网站开发费用摊销几年/宁波网络推广优化方案
  • 网站用axure做的rp格式/ip域名查询网站入口
  • 做视频网站视频短片/推广赚钱一个2元
  • 郑州教育信息网/网站seo推广公司靠谱吗