Ejemplo n.º 1
0
 def test_explicit_retention_policy(self, post):
     client = Client('https://*****:*****@localhost:8086/testdb',
                     retention_policy='rp_four_weeks')
     client.write('temperature', value=21.3, timestamp=1476107241)
     post.assert_called_with(
         'https://localhost:8086/write?precision=s&db=testdb&rp=rp_four_weeks',
         auth=('user', 'pass'),
         data='temperature value=21.3 1476107241')
Ejemplo n.º 2
0
    def test_connection(self):
        """ Should be able to pass a http connection URI. """
        client = Client('http://*****:*****@localhost:8086/databasename')

        assert client.connection.auth == ('user', 'pass')
        assert client.connection.uri == 'http://localhost:8086'
        assert client.connection.db == 'databasename'
Ejemplo n.º 3
0
#!/usr/bin/env python

from inflow import Client

client = Client('http://*****:*****@localhost:8086/databasename',
                retention_policy='rp_four_weeks')

client.write('temperature', value=21.3)
Ejemplo n.º 4
0
#!/usr/bin/env python

from inflow import Client

client = Client('http://*****:*****@localhost:8086/databasename')
results = client.query('SELECT * FROM "temperatures"', epoch='s')
Ejemplo n.º 5
0
#!/usr/bin/env python

from inflow import Client

client = Client('http://*****:*****@localhost:8086/databasename',
                timeout=0.01)

client.write('temperature', value=21.3)
Ejemplo n.º 6
0
# --- write to the DB on the server directly:
# ssh tpc14 ;influx -precision rfc3339 
# > use influxdb_scs
# > SHOW FIELD KEYS FROM "osubw"
# > SELECT * FROM "osubw"

# --- or send data to the DB from daint:
# ----------> ~/linux.git/hpc/gpu/g2g.sh

# module load daint-gpu
# module use /apps/daint/UES/jenkins/daint-gpu-jenkins-testPR/modules/all
# module load influxdb/4.0.0-CrayGNU-2016.11-Python-3.5.2

from inflow import Client
client = Client('http://tpc14.cscs.ch:8086/influxdb_scs')
# client = Client('http://gorner02.cscs.ch:8086/influx_scs')
# , precision='ms')
# client.write('temperature', value=21.3, timestamp=1476191999000)
# results = client.query('SELECT * FROM "temperature"')
# res = client.query('SELECT * FROM "osubw"')
res = client.query('SHOW FIELD KEYS FROM "osubw"')
print (res)
# client.query('SELECT * FROM "temperature"')
# client.query('SHOW FIELD KEYS from "temperature"')

# client.query('DROP SERIES FROM "temperature"')
# , epoch='s')

#cscs: datetimeinflux=`date -d "$datetime" +%s%N`
# date -d @1476191999000 --> Mon Aug 30 15:03:20 CEST 48748
Ejemplo n.º 7
0
 def test_bad_uri(self):
     """ Should throw a ValueError when the given uri is not valid. """
     with pytest.raises(ValueError):
         Client('invalid')
Ejemplo n.º 8
0
 def test_no_database_name(self):
     """ A database name should be specified. """
     with pytest.raises(ValueError):
         Client('https://localhost:8086/')
Ejemplo n.º 9
0
 def test_bad_scheme(self):
     """ Currently we only support the http and https schemes. """
     with pytest.raises(ValueError):
         Client('udp://localhost:8086/databasename')
Ejemplo n.º 10
0
 def test_no_port(self):
     """ Should be able to not provide a port. """
     client = Client('http://localhost/databasename')
     assert client.connection.uri == 'http://localhost'
Ejemplo n.º 11
0
 def test_no_auth(self):
     """ Should be able to parse connection uri without auth. """
     client = Client('http://localhost:8086/databasename')
     assert client.connection.auth is None
Ejemplo n.º 12
0
def client():
    return Client('https://*****:*****@localhost:8086/testdb', timeout=1)
Ejemplo n.º 13
0
#!/usr/bin/env python

from inflow import Client
client = Client('http://*****:*****@localhost:8086/databasename',
                precision='ms')
client.write('temperature', value=21.3, timestamp=1476191999000)
Ejemplo n.º 14
0
#!/usr/bin/env python

from inflow import Client, Measurement

client = Client('http://*****:*****@localhost:8086/databasename')

client.write([
    Measurement(name='temperature',
                tags={
                    'location': 'groningen',
                    'sensor_type': 'ni1000'
                },
                value=21.3,
                timestamp=1475845863),
    Measurement(name='temperature',
                tags={
                    'location': 'groningen',
                    'sensor_type': 'ni1000'
                },
                value=20.1,
                timestamp=1475848864)
])
Ejemplo n.º 15
0
#!/usr/bin/env python

from inflow import Client

client = Client('http://*****:*****@localhost:8086/databasename')

temperature = dict(name='temperature',
                   tags={
                       'location': 'groningen',
                       'sensor_type': 'ni1000'
                   })

client.write(temperature, [{
    'value': 21.3,
    'timestamp': 1475845863
}, {
    'value': 20.1,
    'timestamp': 1475846182
}])
Ejemplo n.º 16
0
#!/usr/bin/env python

from inflow import Client

client = Client('http://*****:*****@localhost:8086/databasename')

client.write('temperature',
             timestamp=1475846182,
             lower_sensor=20.9,
             upper_sensor=23.2)