传动系统客户端

driveline的Python项目详细描述


驱动程序python sdk

Python SDK的核心是类DrivelineClient

importasynciofromdrivelineimportDrivelineClient,run_asyncasyncdefmain():asyncwithDrivelineClient('ws://127.0.0.1:8080')asclient:# list all streamsasyncforstream_nameinawaitclient.list_streams('*'):print('found stream:',stream_name)# list all keys is the document storeasyncforkey_nameinawaitclient.list_keys('*'):print('found document with key',key_name)# store a document in the document storeawaitclient.store('key/1',dict(title='Welcome',body='Hello, world!'))# load a key from the document storefuture_record=awaitclient.load('key/1')record=awaitfuture_recordprint('document associated with key/1 is:',record.record,'id:',record.record_id)# remove all records in the document store with keys matching 'key/...'awaitclient.removeMatches('key/*')# run a live query against a stream. # We want all records that have an odd indexdefquery_handler(res):print('query returned record:',res.record,'id:',res.record_id)query=awaitclient.continuous_query('SELECT * FROM STREAM my_stream where index % 1 == 1',query_handler)# stop the queryawaitasyncio.sleep(10)awaitclient.cancel(query)# quitawaitclient.close()if__name__=='__main__':run_async(main())

DQL动力传动系统查询语言

查询语法

基本语法

SELECT<selector>FROMSTREAM<stream>[WHERE<expression>]SELECT*FROMSTREAMstream_1SELECT*FROMSTREAMstream_1WHEREkey=valueSELECTtimeASt,(2+3)ASfiveFROMSTREAMstream_1WHEREageBETWEEN21AND25ORnameLIKE'Joe%'

DQL支持标准的查询语法,不包括连接和 聚合。这意味着DQL可以用于所有形式的数据过滤 以及在实时流上对数据进行分区

KV查询

SELECT<selector>FROM<string-key-name-expression>[WHERE<expression>]SELECT*FROM'users/*'WHEREcolor='red'

多键查询是一个DQL扩展,允许您订阅多个 事件流,在新流形成时自动订阅它们, 基于流名称表达式。流名称表达式使用文件系统/pythongGlob, 使用?***作为通配符匹配字符。

ecmascript对象表示法(javascript扩展)

SELECT{time,name:user.name,phone_number:user.phone.mobile.number,original:{...*}}FROMstream

以表格形式输入:

{time:123,user:{name:'joe',phone:{mobile:{number:'1-800-123-4567'}}}}

结果:

{time:123,name:'joe',phone_number:'1-800-123-4567',original:{time:123,user:phone:{...}}}

运算符

下表按以下顺序汇总了所有语言运算符 优先级

NameDescriptionExampleAdditional details
^{}extended logical OR^{}^{}
^{}logical AND^{}^{}
^{}logical NOT^{}^{}
^{}Null check^{}^{}
^{}Set lookup^{}All values in paranthesis must be constants
^{}Compare range^{}^{}
^{} ^{} ^{} ^{} ^{} ^{} ^{} ^{} ^{}Compare^{}
^{}Pattern match^{}^{} stands for single, ^{} stands for multi-char match
^{} ^{}Unary plus/minus^{}
^{} ^{}Addition^{}
^{} ^{} ^{}Multiplicative^{}
^{}Paranthesis^{}
^{} ^{} ^{}Constant^{}
^{}Numeric constant
^{}String constant^{}
^{}Identifier^{}
^{}Identifier^{}(backticks) Allows using identifier names that are otherwise invalid, e.g., contain invalid characters or symbols

内置函数

NameDescriptionExample
ABSAbsolute value ^{}^{} ^{}
CEILRounded up value ^{}^{} ^{}
FLOORRounded down value ^{}^{} ^{}
EXPNatural exponent ^{}^{} ^{}
LNNatural logarithm ^{}^{} ^{}
SQRTSquare root ^{}^{} ^{}
HASHHash function ^{}^{} ^{}
CHAR_LENGTHLength of string ^{}^{} ^{}
POSITIONIndex of substring in string ^{}^{} ^{}
LOCATEIndex of substring in string ^{}^{} ^{}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何将jasper集成到jhipster项目中   java无法忽略lombok注释   关于tomcat日志的java问题   java@Autowired未设置字段>NullPointerException   GUI提交按钮不工作   java气泡和选择排序   java如何编写规则来匹配两个数组?   java如何找出某个字符在字符串中的第一次、第二次或第三次出现?   java通过字符串引用id   javascript在网络视图中加载在线图表   java保留web应用程序中用户更改的日志   在安卓中尝试使用Mandrill SMTP发送电子邮件时出现java错误   用java语言将a2b4c5等字符串转换为AABBCCCCC的程序是什么?   java无需TODO即可删除所有注释   java JMX MBean在应用程序部署时自动注册   java如何使用JSON解析从任何url解析数据   java@transactional注释类使用代理包装,但未创建事务   JavaFx转换和打印