IntroxDB客户端
influx-client的Python项目详细描述
涌入客户端
与1.5兼容的IntroxDB客户端。这个客户使用 要提供的请求库 为给定的每个唯一infloxdb url建立连接池。
这个infloxdb客户端由axiom创建、维护和支持。 火用
先决条件
这个客户机只针对infloxdb1.5和python 3.5进行了测试和使用。 如果您想支持任何其他环境,请提交拉取请求。
安装
您可以通过pypi安装这个客户机
$ pip install influx-client
或者克隆此存储库:
$ git clone https://github.com/AxiomExergy/influx-client.git $ cd influx-client $ pip install . # For a regular install $ python setup.py develop # OR for a development install
用法
本节介绍基本用法。
快速启动示例
infloxdb客户端的设计非常简单。它需要一个指向
infloxdb api,否则根据write()
打电话.
如果infloxdb api返回一个错误,即所选数据库不存在,
客户端将发出创建数据库…
查询,然后重试
写入请求。
frominfluximportInfluxDB# This creates the client instance... subsequent calls with the same URL will# return the exact same instance, allowing you to use socket pooling for faster# requests with less resources.client=InfluxDB('http://127.0.0.1:8086')# Creating the database is optional - calls to write() will try to create the# database if it does not exist.client.create_database('mydatabase')# You can write as many fields and tags as you like, or override the *time* for# the data pointsclient.write('mydatabase','mymeasurement',fields={'value':1.0},tags={'env':'example'})# You can write multiple datapoints at a timeclient.write_many('mydatabase','mymeasurement',fields=['value','alpha'],values=[[1.0,0.5],[1.1,0.6]],tags={'env':'example'})# You can query for data relative to now()data=client.select_recent('mydatabase','mymeasurement',time_relative='1h')# You can query with arbitrary WHERE clauses and LIMITsdata=client.select_where('mydatabase','mymeasurement',where='time > 0',limit=1)# You can clean up after yourself, for example in testing environmentsclient.drop_measurement('mymeasurement','mydatabase')# You can also drop the entire database, if necessaryclient.drop_database('mydatabase')# Subsequent client creation will give the same instanceclient2=InfluxDB('http://127.0.0.1:8086')clientisclient2# This is True
开发
本节介绍了流入客户机的开发和贡献。
- 开发是在github上进行的。
- 安装是通过pypi
- 问题是github上的
- 版本是on Github
贡献者
此部分列出了参与此项目的所有人。
- shakefu(创建者、维护者)
存储库布局
这个存储库中有几个重要的部分:
inflix/
-inflix python包测试/
-python notestsdockerfile
,docker compose.yml
-用于测试的docker配置许可证
,readme.md
-文档和法律
运行测试
您可以使用 Docker撰写
以下命令将生成测试映像并运行所有测试:
docker-compose up --build --force-recreate --remove-orphans --exit-code-from influx
测试完成后,您可以使用:
docker-compose down
发出拉取请求
拉取请求必须传递要考虑包含的ci。如果你的请求 没有压缩提交,提交应遵循主题: 说明样式。有关示例,请参见提交历史记录。
API
本节介绍inflox client的公共api
inflox.client(
url,timeout=60,precision='u'
)
帮助器方法,允许您直接从 顶级套餐。
- url(str)-导入API的URL(必需的)
- 超时(int,默认值
60
)-请求超时(秒) - 精度(str,默认值
'u'
)-用于查询的精度字符串
流入数据库(
url,超时=60,精度='u'
)
这是infloxdb的主要客户。它作为每个url的单实例工作。 在基于线程或事件循环的环境中,它依赖于请求 线程的库连接池(反过来依赖于urllib3) 安全性:
- url(str)-infloxdbapi的url(例如http://127.0.0.1:8086')
- 超时(int,默认值
60
)-请求超时(秒) - 精度(str,默认值
'u'
)-用于查询的精度字符串 流入数据库。([见文件] (https://docs.infloxdata.com/infloxdb/v1.5/tools/api/query)什么是 提供。)
创建数据库(
数据库
)
向infloxdb api发出创建数据库…
请求。这是一个
等幂运算。
- 数据库(str)-数据库名称
删除数据库(
数据库
)
向infloxdb api发出删除数据库…
请求。这将导致404
如果数据库不存在,则返回httperror。
- 数据库(str)-数据库名称
放下测量(
测量,数据库
)
发出一个drop measurement…
对指定数据库的infloxdb api的请求。
- 测量(str)-测量名称
- 数据库(str)-测量值位于其中的数据库
写入(
数据库、测量、字段、标记{},时间=无
)
将数据点写入指定的数据库和测量
- 数据库(str)-数据库名称
- 测量(str)-测量名称
- 字段(dict)-字段名称字典:值数据点
- 标记(dict,可选)-标记名称字典:值 与数据点关联
- 时间(日期时间,可选)-要使用的日期时间,而不是infloxDB的 服务器端"现在"
。编写大量(
数据库、测量、字段、值、标记{},时间字段=无
)
将数据点写入指定的数据库和测量
- 数据库(str)-数据库名称
- 测量(str)-测量名称
- 字段(列表)-字段名列表,顺序与值相同
- 值(列表)-值列表(列表列表)
- 标记(dict,可选)-标记名称字典:值 与数据点关联
- 时间字段(str,可选)-要提取并用作时间戳的字段名
。选择"最近"(
数据库、测量、字段="*"、标记={}、相对时间="15m"
)
使用字段在数据库中查询infloxdb api以获取度量值。 字符串,仅限于在最近的相对时间内匹配标记
从infloxdb返回原始json响应。
- 数据库(str)-数据库名称
- 测量(str)-测量名称
- 字段(str,默认值为
'*'
)-字符串格式的字段,用于选择
查询 - 标记(dict,可选)-要匹配的标记的字典
- 相对时间(str,默认值
'15m'
)-相对时间字符串
。选择"U where"(
数据库、测量、字段='*',标记={},where='time>;now()-15m',desc=false,limit=none
)
查询infloxdb api用于数据库中的测量,使用字段 字符串,仅限于将标记与where子句匹配,并应用限制。
从infloxdb返回原始json响应。
- 数据库(str)-数据库名称
- 测量(str)-测量名称
- 字段(str,默认值为
'*'
)-字符串格式的字段,用于选择
查询 - 标记(dict,可选)-要匹配的标记的字典
- where(str,默认
'time>;now()-15m'
)要添加的where子句 - desc(bool,默认值
false
)添加按时间顺序desc
子句 - 限制(int,可选)限制此数量的数据点
。选择"进入"(
[数据库,]目标、源、字段="*",其中=无,分组依据="*"
)
返回选定对象移动的数据点计数…进入…从…查询,
查询将遵循以下格式:
SELECT *fields* INTO *target* FROM *source* WHERE *where* GROUP BY *group_by*
where和group by子句是可选的。
注意,如果不包括group by*或显式调用标记, 标记将记录为字段。
- 数据库(str)数据库名称(可选)
- 目标(str)目标测量
- 震源(str)震源测量
- select子句的fields部分(可选, 默认值:"*")
- where(str)select子句的where部分(可选)
- 分组依据(str)选择子句的分组依据部分(可选, 默认值:"*")
如果希望指定 带有数据库的完全限定测量名称。
示例:
InfluxDB().select_into('database','target','source')# Is the same asInfluxDB().select_into('database.default.target','database.default.source')# Where often the default is 'autogen'
。显示标签(
数据库,测量
)
查询infloxdbapi并返回数据库中的标记名列表 测量
- 数据库(str)-数据库名称
- 测量(str)-测量名称
。显示字段(
数据库,测量
)
查询infloxdbapi并返回数据库中的字段名列表 测量
- 数据库(str)-数据库名称
- 测量(str)-测量名称
许可证
此存储库及其代码库在apache许可证下公开 V2.0 我们要求,如果您确实使用此项工作,请将axiom属性axiom 火用并链接到原始存储库。
更改日志
有关 详细的发行说明。