Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit b75182a

Browse files
committed
tutorial for bind_params
1 parent 0e00f32 commit b75182a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

examples/tutorial.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ def main(host='localhost', port=8086):
1313
dbname = 'example'
1414
dbuser = 'smly'
1515
dbuser_password = 'my_secret_password'
16-
query = 'select value from cpu_load_short;'
16+
query = 'select Float_value from cpu_load_short;'
17+
query_where = 'select Int_value from cpu_load_short where host=$host;'
18+
bind_params = {'host': 'server01'}
1719
json_body = [
1820
{
1921
"measurement": "cpu_load_short",
@@ -50,6 +52,11 @@ def main(host='localhost', port=8086):
5052

5153
print("Result: {0}".format(result))
5254

55+
print("Querying data: " + query_where)
56+
result = client.query(query_where, bind_params=bind_params)
57+
58+
print("Result: {0}".format(result))
59+
5360
print("Switch user: " + user)
5461
client.switch_user(user, password)
5562

0 commit comments

Comments
 (0)