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

Commit b490d53

Browse files
committed
Merge pull request #1 from smly/feature/implement
Implement python-client for InfluxDB
2 parents 5ad1f07 + 2f53498 commit b490d53

File tree

14 files changed

+889
-0
lines changed

14 files changed

+889
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
influxdb.egg-info/
2+
*.pyc
3+
*.py.swp
4+
.tox

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: python
2+
python:
3+
- "3.3"
4+
- "3.2"
5+
- "2.7"
6+
install:
7+
- "pip install -r requirements.txt --use-mirrors"
8+
- "pip install -r test-requirements.txt --use-mirrors"
9+
script: nosetests

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include requirements.txt
2+
include test-requirements.txt

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,18 @@ influxdb-python
22
===============
33

44
Python client for InfluxDB
5+
6+
For developers
7+
--------------
8+
9+
To test influxdb-python with multiple version of Python, you can use tox:
10+
11+
````
12+
$ tox
13+
````
14+
15+
If you don't have all Python version listed in tox.ini, then
16+
17+
````
18+
$ tox -e py27
19+
````

examples/tutorial.py

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import argparse
2+
3+
from influxdb import InfluxDBClient
4+
5+
6+
def main(host=None, port=None):
7+
user = 'root'
8+
password = 'root'
9+
dbname = 'example'
10+
dbuser = 'smly'
11+
dbuser_password = 'my_secret_password'
12+
query = 'select column_one from foo;'
13+
json_body = [
14+
{
15+
"points": [
16+
["1", 1, 1.0],
17+
["2", 2, 2.0]
18+
],
19+
"name": "foo",
20+
"columns": ["column_one", "column_two", "column_three"]
21+
}
22+
]
23+
24+
25+
client = InfluxDBClient(host, port, user, password, dbname)
26+
27+
print("Create database: " + dbname)
28+
client.create_database(dbname)
29+
30+
dbusers = client.get_database_users()
31+
print("Get list of database users: {0}".format(dbusers))
32+
33+
print("Add database user: " + dbuser)
34+
client.add_database_user(dbuser, dbuser_password)
35+
36+
dbusers = client.get_database_users()
37+
print("Get list of database users again: {0}".format(dbusers))
38+
39+
print("Swtich user: " + dbuser)
40+
client.switch_user(dbuser, dbuser_password)
41+
42+
print("Write points: {0}".format(json_body))
43+
client.write_points(json_body)
44+
45+
print("Queying data: " + query)
46+
result = client.query(query)
47+
48+
print("Result: {0}".format(result))
49+
50+
print("Swtich user: " + user)
51+
client.switch_user(user, password)
52+
53+
print("Delete database: " + dbname)
54+
client.delete_database(dbname)
55+
56+
57+
def parse_args():
58+
parser = argparse.ArgumentParser(
59+
description='example code to play with InfluxDB')
60+
parser.add_argument('--host', type=str, required=True)
61+
parser.add_argument('--port', type=int, required=True)
62+
return parser.parse_args()
63+
64+
65+
if __name__ == '__main__':
66+
args = parse_args()
67+
main(host=args.host, port=args.port)

influxdb/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# -*- coding: utf-8 -*-
2+
from influxdb.client import InfluxDBClient
3+
4+
5+
__all__ = ['InfluxDBClient']
6+
7+
__version__ = '0.1.1'

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy