10000 Implement python-client for InfluxDB by smly · Pull Request #1 · influxdata/influxdb-python · GitHub
[go: up one dir, main page]

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

Implement python-client for InfluxDB #1

Merged
merged 2 commits into from
Nov 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
influxdb.egg-info/
*.pyc
*.py.swp
.tox
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: python
python:
- "3.3"
- "3.2"
- "2.7"
install:
- "pip install -r requirements.txt --use-mirrors"
- "pip install -r test-requirements.txt --use-mirrors"
script: nosetests
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include requirements.txt
include test-requirements.txt
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@ influxdb-python
===============

Python client for InfluxDB

For developers
--------------

To test influxdb-python with multiple version of Python, you can use tox:

````
$ tox
````

If you don't have all Python version listed in tox.ini, then

````
$ tox -e py27
````
67 changes: 67 additions & 0 deletions examples/tutorial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import argparse

from influxdb import InfluxDBClient


def main(host=None, port=None):
user = 'root'
password = 'root'
dbname = 'example'
dbuser = 'smly'
dbuser_password = 'my_secret_password'
query = 'select column_one from foo;'
json_body = [
{
"points": [
["1", 1, 1.0],
["2", 2, 2.0]
],
"name": "foo",
"columns": ["column_one", "column_two", "column_three"]
}
]


client = InfluxDBClient(host, port, user, password, dbname)

print("Create database: " + dbname)
client.create_database(dbname)

dbusers = client.get_database_users()
print("Get list of database users: {0}".format(dbusers))

print("Add database user: " + dbuser)
client.add_database_user(dbuser, dbuser_password)

dbusers = client.get_database_users()
print("Get list of database users again: {0}".format(dbusers))

print("Swtich user: " + dbuser)
client.switch_user(dbuser, dbuser_password)

print("Write points: {0}".format(json_body))
client.write_points(json_body)

print("Queying data: " + query)
result = client.query(query)

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

print("Swtich user: " + user)
client.switch_user(user, password)

print("Delete database: " + dbname)
client.delete_database(dbname)


def parse_args():
parser = argparse.ArgumentParser(
description='example code to play with InfluxDB')
parser.add_argument('--host', type=str, required=True)
parser.add_argument('--port', type=int, required=True)
return parser.parse_args()


if __name__ == '__main__':
args = parse_args()
main(host=args.host, port=args.port)
7 changes: 7 additions & 0 deletions influxdb/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
from influxdb.client import InfluxDBClient


__all__ = ['InfluxDBClient']

__version__ = '0.1.1'
Loading
0