influxdb-matlab:用于InfluxDB的MATLAB客户端

  • A4_778904
    了解作者
  • 20.5KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-28 12:04
    上传日期
influxdb-matlab:用于InfluxDB的MATLAB客户端
influxdb-matlab-master.zip
  • influxdb-matlab-master
  • influxdb-client
  • SeriesResult.m
    5.7KB
  • TimeUtils.m
    4.2KB
  • iif.m
    88B
  • QueryBuilder.m
    8.8KB
  • Series.m
    6.1KB
  • InfluxDB.m
    4.9KB
  • forEachPair.m
    608B
  • QueryResult.m
    3KB
  • WriteBuilder.m
    2.1KB
  • tests
  • SeriesTest.m
    13.6KB
  • QueryBuilderTest.m
    11.9KB
  • InfluxDbTest.m
    3.5KB
  • .travis.yml
    270B
  • LICENSE
    1KB
  • README.md
    6.5KB
  • .gitignore
    359B
  • run_tests.m
    680B
内容介绍
InfluxDB MATLAB =============== This is a [MATLAB][matlab] client library for interacting with [InfluxDB][influxdb]. The library has been tested with `InfluxDB 1.5` and `MATLAB R2018a`. Earlier versions of InfluxDB or MATLAB may also work but have not been tested. Installation ------------ Clone or download the repository and add the `influxdb-client` directory to the path: ```matlab % Add the library to the path addpath('path/to/influxdb-client'); ``` Usage ----- Create an InfluxDB client instance and use it to interact with the server: ```matlab % Build an InfluxDB client URL = 'http://localhost:8086'; USER = 'user'; PASS = 'password'; DATABASE = 'server_stats'; influxdb = InfluxDB(URL, USER, PASS, DATABASE); % Check the status of the InfluxDB instance [ok, ping] = influxdb.ping() % Show the databases dbs = influxdb.databases() % Change the current database influxdb.use('weather_stations'); ``` If you plan on doing very large requests you may need to adjust the timeouts: ```matlab % Configure timeouts influxdb.setReadTimeout(10); influxdb.setWriteTimeout(10); ``` Writing data ------------ Use the `Series` builder to prepare the data, then write it using the client: ```matlab % Create a series with a single sample series1 = Series('weather') ... .tags('city', 'barcelona', 'country', 'catalonia') ... .fields('temperature', 24.3, 'humidity', 70.4) ... .time(datetime('today', 'TimeZone', 'local')); % Create a series with many samples series2 = Series('weather') ... .tags('city', 'copenhagen', 'country', 'denmark') ... .fields('temperature', [12.6; 11.8], 'humidity', [45.7; 46.3]) ... .time(datetime('now', 'TimeZone', 'local') - [0; 1] / 24); % Create a series from an existing timetable series3 = Series('weather') ... .tags('city', 'helsinki', 'country', 'finland') ... .import(my_timetable); % Create an array of series series_array = [series4, series5, etc]; % Save all the series in a batch influxdb.writer() ... .append(series1, series2, series3) ... .append(series_array) ... .execute(); ``` The parameters of a write request can optionally be customized as follows: ```matlab % Customize a write request influxdb.writer() ... .database('another_database') ... .precision('ms') ... .retention('two_weeks') ... .consistency('quorum') ... .append(series, etc) ... .execute(); ``` Querying data ------------- The client supports reading data from InfluxDB using query strings: ```matlab % Manually written query str = 'SELECT temperature FROM weather WHERE humidity > 60 LIMIT 100'; result = influxdb.runQuery(str); ``` Additionally, a query builder is provided to help generate them: ```matlab % Dynamically generated query result = influxdb.query('weather') ... .fields('temperature', 'humidity') ... .tags('city', 'barcelona') ... .tagsLike('station', '^(foo|bar)[0-9]{3}') ... .before(datetime('today', 'TimeZone', 'local')) ... .after(datetime('2018-01-01', 'TimeZone', 'local')) ... .where('temperature > 20 AND humidity > 60') ... .execute(); % Another example with more options result = influxdb.query('weather') ... .fields('mean(temperature)', 'sum(rain)') ... .groupByTags('country', 'city') ... .groupByTime('3h', 'linear') ... .limit(100) ... .execute(); ``` The parameters of a query request can optionally be customized as follows: ```matlab % Customize a query request result = influxdb.query('weather') ... .database('another_database') ... .epoch('m') ... .execute(); ``` The result of a query is an object that provides additional functionalities: ```matlab % Check which series are present in a result series_names = result.names() % Get series with matching name weather = result.series('weather') % When grouping by tags, get series with matching tags weather_bcn = result.series('weather', 'city', 'barcelona') weather_cph = result.series('weather', 'city', 'copenhagen') % Check which fields are present in a series field_names = weather.fields() % Plot a field time = weather.time('Europe/Amsterdam'); temperature = weather.field('temperature'); plot(time, temperature); % Convert a series to a table or timetable mytable = weather.table(); mytable = weather.timetable('Europe/Paris'); ``` Notice that the `time()` and `timetable()` methods take an optional timezone argument. Other commands -------------- Use `runCommand(command, [database], [requiresPost])` for executing arbitrary commands: ```matlab % Show databases then create one influxdb.runCommand('SHOW DATABASES') influxdb.runCommand('CREATE DATABASE "example"', true) % Show measurements and tag keys influxdb.runCommand('SHOW MEASUREMENTS', 'example') influxdb.runCommand('SHOW TAG KEYS', 'example') % Create a retention policy that keeps data for one day influxdb.runCommand('CREATE RETENTION POLICY "one_day" ON "example" DURATION 1d REPLICATION 1', true) % Convert a command result to a table result = influxdb.runCommand('SHOW RETENTION POLICIES', 'example') policies = result.series().table() ``` See the [InfluxDB documentation][influxdb-docs] for more schema exploration and management commands. Contributing ------------ Feedback or contributions are welcome! Please create an issue to discuss it first :) License ------- MIT License Copyright (c) 2018 Enric Sala Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. [matlab]: https://en.wikipedia.org/wiki/MATLAB [influxdb]: https://en.wikipedia.org/wiki/InfluxDB [influxdb-docs]: https://docs.influxdata.com/influxdb
评论
    相关推荐
    • Matlab合集
      冈萨雷斯数字图像处理MATLAB版.中文版+数字图像处理第二版中文版(冈萨雷斯)+MATLAB-R2014a完全自学一本通+MATLAB R2016a完全自学一本通 素材文件+[模式识别与智能计算:MATLAB技术实现(第2版)].杨淑莹.扫描版
    • MATLAB教程
      MATLAB教程MATLAB教程MATLAB教程MATLAB教程MATLAB教程MATLAB教程
    • MATLAB
      MATLAB 该项目是在matlab上完成的,涉及创建和移动宇宙飞船和机器人。 太空飞船和机器人是使用Matlab中的简单几何形状创建的,并通过连续变换矩阵进行移动。 这个项目教我如何使用变换矩阵(旋转,平移等)的概念...
    • MATLAB基础
      一本学习matlab的一本好书
    • MATLAB编译器
      基于MATLAB 2018b版本介绍MATLAB编译器。介绍如何利用编译器将MATLAB代码编译为独立应用程序或组件,并在没有安装MATLAB的计算机上进行部署。
    • matlabruntime
      通过奇点容器运行您的matlab项目 可以在没有MATLAB的容器中运行matlab代码。 为此,我们首先需要通过Matlab编译器在本地构建相应的Matlab代码的独立应用程序,然后使用具有Matlab运行时( 的容器)运行该应用程序 )...
    • matlab实现
      matlab实现 matlab实现matlab实现matlab实现matlab实现
    • matlab 教程
      matlab 信号处理资料,里面包含信号处理pdf文档,一些杂乱的程序和命令等
    • matlab教程
      matlab教程,PPT格式,包含 matlab基本知识、matlab入门、matlab作图、线性规划、无约束优化、非线性规划、统计工具箱、差值、微分方程等多项知识点,并且每个知识点独立成为PPT,内还含有matlab信号处理详解等文档...
    • matlab简介
      1.MATLAB 开发环境 1.1 MATLAB 的视窗环境 进入MATLAB之后,会看到一个视窗MATLAB Command Window称为指令视窗,它是你键入指令的地方同时 MATLAB也将计算结果显示在此。 1.2 简易计算 我们先从MATLAB的...