@@ -44,7 +44,7 @@ supplied UUID cannot be found then :code:`None` will be returned.
4444 stream = conn.stream_from_uuid(" 71466a91-dcfe-42ea-9e88-87c51f847942" )
4545
4646
47- Query by collection
47+ Finding by collection
4848--------------------------
4949You can also search for multiple streams by collection using the server object's
5050:code: `streams_in_collection ` method which will return a simple list of
@@ -56,3 +56,44 @@ detail.
5656
5757 conn = btrdb.connect()
5858 streams = conn.streams_in_collection(" NORTHEAST/NH" )
59+
60+
61+ Querying Metadata
62+ -----------------
63+ Finally, you can query for metadata using standard SQL although at the moment, only the
64+ `streams ` table is available. SQL queries can be submitted using the `query `
65+ method which accepts both a `stmt ` and `params ` argument. The `stmt ` should
66+ contain the SQL you'd like executed with parameter placeholders such as `$1 ` or
67+ `$2 ` as shown below.
68+
69+ .. code-block :: python
70+
71+ conn = btrdb.connect()
72+ stmt = " select uuid from streams where name = $1 or name = $2"
73+ params = [" Boston_1" , " Boston_2" ]
74+
75+ for row in conn.query(stmt, params):
76+ print (row)
77+
78+ The SQL query results are returned as a list of dictionaries where each key
79+ matches a column from your SQL projection. You can choose your columns from the
80+ schema of the streams table as follows.
81+
82+
83+ +------------------+------------------------+-----------+
84+ | Column | Type | Nullable |
85+ +==================+========================+===========+
86+ | uuid | uuid | not null |
87+ +------------------+------------------------+-----------+
88+ | collection | character varying(256) | not null |
89+ +------------------+------------------------+-----------+
90+ | name | character varying(256) | not null |
91+ +------------------+------------------------+-----------+
92+ | unit | character varying(256) | not null |
93+ +------------------+------------------------+-----------+
94+ | ingress | character varying(256) | not null |
95+ +------------------+------------------------+-----------+
96+ | property_version | bigint | not null |
97+ +------------------+------------------------+-----------+
98+ | annotations | hstore | |
99+ +------------------+------------------------+-----------+
0 commit comments