oneCk是一个PHP实现的ClickHouse TCP协议客户端。
composer require lizhichao/one-ck
php5.6 - php7.1 以下版本不支持 Decimal128 ,请使用0.1.x 的版本
clickhouse QQ交流群 970435787
use OneCk\Client; use OneCk\Types; //default //$ck = new Client('tcp://127.0.0.1:9000'); $t1 = microtime(true); $ck = new Client('tcp://192.168.31.216:9091', 'default', '123456', 'test1'); $data['server info'] = $ck->getServerInfo(); $data['drop table'] = $ck->query('DROP TABLE IF EXISTS t6'); $table = [ 'CREATE TABLE t6 (', '`id` UInt32,', '`f1` Int32,', '`f2` Nullable(Int32),', '`f3` UInt8,', '`f4` Nullable(UInt8),', '`f5` UInt16,', '`f6` UInt64,', '`f7` Int64,', '`f8` Float32,', '`f9` Float64,', '`f10` Nullable(Float64),', '`f11` Decimal32(3),', '`f12` Decimal64(5),', '`f13` Decimal128(7),', '`f14` Nullable(Decimal128(7)),', '`f15` String,', '`f16` Nullable(String),', '`f17` FixedString(32),', '`f18` UUID,', '`f19` Date,', '`f20` Nullable(Date),', '`f21` Datetime,', '`f22` Datetime64(3),', '`f23` IPv4,', '`f24` Nullable(IPv4),', '`f25` IPv6,', '`f26` LowCardinality(String),', '`f27` Array(Int32),', '`f28` Array(Array(Array(Nullable(Date)))),', '`f29` Array(Array(Array(Array(Array(Nullable(Datetime))))))', ') ENGINE = MergeTree() ORDER BY id SETTINGS index_granularity = 8192' ]; $data['create table'] = $ck->query(implode("\n", $table)); $data['insert data'] = $ck->insert('t6', [ [ 'id' => 1, 'f1' => -3, 'f2' => null, 'f3' => 127, 'f4' => null, 'f5' => 3322, 'f6' => 1844674407370955161, 'f7' => 9223372036854775807, 'f8' => -2132121.5, 'f9' => 6546546544665.66658, 'f10' => null, 'f11' => 552.339, 'f12' => 3658.6954, 'f13' => '170141183460469231168730371588.4105721', 'f14' => null, 'f15' => 'emoji����������', 'f16' => null, 'f17' => md5('a'), 'f18' => '016e64be-605f-4108-8a67-495d74d7ef3c', 'f19' => '2020-09-05', 'f20' => null, 'f21' => '2020-09-05 14:25:12', 'f22' => '2020-09-05 14:25:12.258', 'f23' => '192.168.1.1', 'f24' => null, 'f25' => 'CDCD:910A:2222:5498:8475:1111:3900:2020', 'f26' => 'eee', 'f27' => [0, -2, 3, 4, 5, 6, 7, 8, 64], 'f28' => [[['2020-01-05', null, '2020-01-06']], [['2020-01-07'], ['2020-01-08']], [['2020-01-09']]], 'f29' => [[[[["2020-01-05 05:05:05", null, "2020-01-06 15:16:17"]], [["2020-01-07 18:19:20"], ["2020-01-08 21:22:23"]], [["2020-01-09 00:00:00"]]], [[["2020-01-10 01:00:00", null]]]], [[[["2020-01-11 00:00:01", null, "2020-01-12 11:01:58"]], [["2020-01-13 21:22:01"]]]]] ], [ 'id' => 2, 'f1' => 3, 'f2' => 3, 'f3' => 3, 'f4' => 3, 'f5' => 3, 'f6' => 3, 'f7' => 3, 'f8' => 3, 'f9' => 3, 'f10' => 3, 'f11' => -552.339, 'f12' => -3658.6954, 'f13' => '-170141183460469231168730371588.4105721', 'f14' => 3, 'f15' => str_repeat(md5('aa'), '6'), 'f16' => '', 'f17' => md5('55'), 'f18' => md5('55'), 'f19' => '2020-09-06', 'f20' => '2020-09-06', 'f21' => '2020-09-06 14:25:12', 'f22' => '2020-09-06 14:25:12.258', 'f23' => '251.222.221.231', 'f24' => '192.168.1.2', 'f25' => '1030::C9B4:FF12:48AA:1A2B', 'f26' => 'eee22', 'f27' => [1, 2, 3, 4], 'f28' => [[['2020-01-05', '2020-01-06']], [['2020-01-07', null], ['2020-01-08']], [['2020-01-09']]], 'f29' => [[[[[null]]]]] ], [ 'id' => 3, 'f1' => -1, 'f2' => 3, 'f3' => 3, 'f4' => 3, 'f5' => 3, 'f6' => 3, 'f7' => 3, 'f8' => 3, 'f9' => 3, 'f10' => 3, 'f11' => 3, 'f12' => 3, 'f13' => 3, 'f14' => 3, 'f15' => 'aaa', 'f16' => 'aaa', 'f17' => md5('a'), 'f18' => '3026ee79-ac2a-46d2-882d-959a55d71025', 'f19' => '2020-09-07', 'f20' => '2020-09-07', 'f21' => '2020-09-07 14:25:12', 'f22' => '2020-09-07 14:25:12.258', 'f23' => '192.168.1.1', 'f24' => null, 'f25' => '2001:DB8:2de::e13', 'f26' => 'eee22', 'f27' => [12344], 'f28' => [[['2020-01-05', '2020-01-06'], [null]], [['2020-01-07'], ['2020-01-08']], [['2020-01-09']]], 'f29' => [[[[['2018-01-25 11:25:14']]]]] ] ]); //$data['struct'] = $ck->query('desc t6'); $data['select t6'] = $ck->query('select * from t6'); $data['select t6 int64'] = $ck->query("select id,f6 from t6 where f6=1844674407370955161"); $data['select t6 Decimal32'] = $ck->query("select id,f11 from t6 where f11='552.339'"); $data['select t6 Decimal64'] = $ck->query("select id,f12 from t6 where f12='-3658.69540'"); $data['select t6 Decimal128'] = $ck->query("select id,f13 from t6 where f13='170141183460469231168730371588.4105721'"); $data['select t6 uuid'] = $ck->query("select id,f18 from t6 where f18='3026ee79-ac2a-46d2-882d-959a55d71025'"); $data['select t6 date'] = $ck->query("select id,f19 from t6 where f19='2020-09-05'"); $data['select t6 datetime'] = $ck->query("select id,f21 from t6 where f21='2020-09-07 20:25:12'"); $data['select t6 datetime64'] = $ck->query("select id,f22 from t6 where f22='2020-09-06 20:25:12.258'"); $data['select t6 ip'] = $ck->query("select id,f23,f25 from t6 where f23=" . Types::encodeIpv4('192.168.1.1')); $data['select t6 ip64'] = $ck->query("select id,f23,f25 from t6 where f25='" . Types::encodeIpv6('1030::c9b4:ff12:48aa:1a2b') . "'"); $data['nothing'] = $ck->query('select array()'); // flow of write $data['drop table'] = $ck->query('DROP TABLE IF EXISTS t7'); $table = [ 'CREATE TABLE t7 (', '`id` UInt32,', '`f2` Nullable(Int32),', '`f5` UInt16,', '`f15` String', ') ENGINE = MergeTree() ORDER BY id SETTINGS index_granularity = 8192' ]; $data['create table'] = $ck->query(implode("\n", $table)); $ck->writeStart('t7',['id','f2','f5','f15']); for ($i = 0; $i < 100; $i++) { $da = []; for ($j = 0; $j < 1000; $j++) { $da[] = [ 'id' => mt_rand(1,1000000), 'f2' => mt_rand(-1000000,1000000), 'f5' => mt_rand(1,10000), 'f15' => md5(mt_rand(1,10000)) ]; } $ck->writeBlock($da); } $ck->writeEnd(); $data['write 10w rows time'] = microtime(true) - $t1; echo json_encode($data);
对于大多数应用程序来说,轻客户端是完整的区块链系统的重要组成部分。Tendermint 为轻客户端应用程序提供了独特的速度和安全性。 请见我们的 lite package。 概述 轻客户端协议的目标是为最近的块哈希获取提交,其中提交包含来自最后一个已知验证者集的大部分签名。从那里,所有的应用状态都可以用默克尔证明进行验证。 属性 你得到了 Tendermint 的全部担保安全优势;不需要等待确认。
连接到服务器 # imaplib_connect.py import imaplib import configparser import os def open_connection(verbose=False): # Read the config file config = configparser.ConfigParser() config.read([os.p
我在套接字上编写客户机-服务器应用程序,我有任务设计我自己的协议。客户端和服务器与XML通信。我使用JAXB库。客户机将XML完美地写入输出流。但我无法在服务器上读取它。你能演示一下如何正确接收客户端的数据吗? 还有我的线。 我应该在服务器上写什么来解析我得到的XML?我尝试解析InputStream。 现在它显示我异常。我改变马歇尔参数。
当需要引导客户端或一些无连接协议时,需要使用Bootstrap类。 在本节中,我们将回顾可用的各种方法引导客户端,引导线程,和可用的管道实现。 客户端引导方法 下表是 Bootstrap 的常用方法,其中很多是继承自 AbstractBootstrap。 Table 9.1 Bootstrap methods 名称 描述 group 设置 EventLoopGroup 用于处理所有的 Channe
下列协程客户端是Swoole内置的类,其中 ⚠️ 标志的不要再使用,使用PHP原生的函数+一键协程化。 协程TCP/UDP客户端 协程HTTP客户端 协程HTTP2客户端 协程PostgreSQL客户端 协程Socket客户端 ⚠️ 协程Redis客户端 ⚠️ 协程MySql客户端 ⚠️ 协程System(Coroutine\System),主要是文件操作相关的不推荐使用。 超时规则 所有的网络请
用途: 与SMTP服务交互,包括发送邮件 发送一封电子邮件 # smtplib_sendmail.py import smtplib import email.utils from email.mime.text import MIMEText # Create the message msg = MIMEText('This is the body of the message.') msg[
!> 本客户端不再推荐使用,推荐使用Swoole\Runtime::enableCoroutine + phpredis 或 predis 的 方式,即一键协程化原生PHP的redis客户端使用. 使用示例 Co\run(function () { $redis = new Swoole\Coroutine\Redis(); $redis->connect('127.0.0.1',
Hyperf 提供了对 WebSocket Client 的封装,可基于 hyperf/websocket-client 组件对 WebSocket Server 进行访问; 安装 composer require hyperf/websocket-client 使用 组件提供了一个 Hyperf\WebSocketClient\ClientFactory 来创建客户端对象 Hyperf\Web