PipelineDB一些重要功能,这里接列一下:
SQL的一些高级应用:
基于PostgreSQL的流式计算数据库PipelineDB
--Output Streams 基于汇总的前后比较
CREATE CONTINUOUS VIEW v_sum AS SELECT sum(x) FROM stream;
CREATE CONTINUOUS VIEW v_deltas AS SELECT abs((new).sum - (old).sum) AS delta
FROM output_of('v_sum')
WHERE abs((new).sum - (old).sum) > 10;
--windows 范围
CREATE CONTINUOUS VIEW v_ttl WITH (ttl = '1 month', ttl_column = 'minute') AS
SELECT minute(arrival_timestamp), COUNT(*) FROM some_stream GROUP BY minute;
--stream dispatch
CREATE CONTINUOUS TRANSFORM t AS
SELECT x::int, y::int FROM stream WHERE mod(x, 2) = 0
THEN EXECUTE PROCEDURE pipeline_stream_insert('even_stream');
数据字典/和执行统计查询
执行情况
pipeline_version ( )
pipeline_views ( )
pipeline_transforms ( )
统计数据
pipeline_query_stats
pipeline_stream_stats
备份/回复
具体见http://docs.pipelinedb.com/backups.html
pipeline-dump > backup.sql
pipeline -f backup.sql
Python连接
Python连接pipelinedb需要安装psycopg2,还是执行SQL语句,具体见http://docs.pipelinedb.com/clients.html
import psycopg2
conn = psycopg2.connect('dbname=test user=user host=localhost port=5432')
pipeline = conn.cursor()
for x in range(10):
rows.append({'x': x})
pipeline.executemany('INSERT INTO stream (x) VALUES (%(x)s)', rows)
PS.
今天把剩下的版本<一切皆有价>看完了,信仰的价格这章很有意思,联想到前几天看的<量子物理史话>最后也变成的一个哲学问题
Matrix是无处不在的,也许这就是现实啊^-^