File tree Expand file tree Collapse file tree 10 files changed +162
-0
lines changed
src/writeData/clients/Dart Expand file tree Collapse file tree 10 files changed +162
-0
lines changed Original file line number Diff line number Diff line change 1+ For more detailed and up to date information check out the [ GitHub Repository] ( https://github.com/influxdata/influxdb-client-dart ) .
2+
3+ ##### Use this package as a library
4+
5+ For Dart run this command:
6+
7+ ```
8+ dart pub add influxdb_client
9+ ```
10+
11+ For Flutter run this command:
12+
13+ ```
14+ flutter pub add influxdb_client
15+ ```
16+
17+ This will add a line like this to your package's ` pubspec.yaml ` :
18+
19+ ```
20+ dependencies:
21+ influxdb_client: ^2.2.0
22+ ```
Original file line number Diff line number Diff line change 1+ client.close();
Original file line number Diff line number Diff line change 1+ var query = '''
2+ <%= query %>
3+ ''';
4+
5+ var queryService = client.getQueryService();
6+
7+ var records = await queryService.query(query);
8+ await records.forEach((record) {
9+ print('${record['_time']}: ${record['_field']} = ${record['_value']}');
10+ });
Original file line number Diff line number Diff line change 1+ import 'dart:io' show Platform;
2+
3+ import 'package:influxdb_client/api.dart';
4+
5+ void main() async {
6+
7+ // You can generate an API token from the "API Tokens Tab" in the UI
8+ var token = Platform.environment['INFLUX_TOKEN'];
9+ var bucket = '<%= bucket %>';
10+ var org = '<%= org %>';
11+
12+ var client = InfluxDBClient(
13+ url: '<%= server %>',
14+ token: token,
15+ org: org,
16+ bucket: bucket);
17+
18+ var query = '''
19+ <%= query %>
20+ ''';
21+
22+ var queryService = client.getQueryService();
23+
24+ var records = await queryService.query(query);
25+ await records.forEach((record) {
26+ print('${record['_time']}: ${record['_field']} = ${record['_value']}');
27+ });
28+
29+ client.close();
30+ }
Original file line number Diff line number Diff line change 1+ import logo from 'src/writeData/clients/Dart/logo.svg'
2+ import description from 'src/writeData/clients/Dart/description.md'
3+ import initialize from 'src/writeData/clients/Dart/initialize.example'
4+ import writeLP from 'src/writeData/clients/Dart/write.0.example'
5+ import writePoint from 'src/writeData/clients/Dart/write.1.example'
6+ import execute from 'src/writeData/clients/Dart/execute.example'
7+ import query from 'src/writeData/clients/Dart/query.example'
8+ import executeFull from 'src/writeData/clients/Dart/executeFull.example'
9+ import dispose from 'src/writeData/clients/Dart/dispose.example'
10+
11+ export default register =>
12+ register ( {
13+ id : 'dart' ,
14+ name : 'Dart' ,
15+ description,
16+ logo,
17+ initialize,
18+ write : [
19+ {
20+ title : 'Use InfluxDB Line Protocol to write data' ,
21+ code : writeLP ,
22+ } ,
23+ {
24+ title : 'Use a Data Point to write data' ,
25+ code : writePoint ,
26+ } ,
27+ ] ,
28+ execute,
29+ query,
30+ executeFull,
31+ dispose,
32+ } )
Original file line number Diff line number Diff line change 1+ import 'dart:io' show Platform;
2+
3+ import 'package:influxdb_client/api.dart';
4+
5+ void main() async {
6+
7+ // You can generate an API token from the "API Tokens Tab" in the UI
8+ var token = Platform.environment['INFLUX_TOKEN'];
9+ var bucket = '<%= bucket %>';
10+ var org = '<%= org %>';
11+
12+ var client = InfluxDBClient(
13+ url: '<%= server %>',
14+ token: token,
15+ org: org,
16+ bucket: bucket);
17+ }
Original file line number Diff line number Diff line change 1+ from(bucket: "<%= bucket %>") |> range(start: -1h)
Original file line number Diff line number Diff line change 1+ var record = 'mem,host=host1 used_percent=23.43234543';
2+
3+ var writeService = client.getWriteService();
4+ await writeService.write(record).then((value) {
5+ print('Write completed');
6+ }).catchError((exception) {
7+ print(exception);
8+ });
Original file line number Diff line number Diff line change 1+ var point = Point('h2o')
2+ .addTag('location', 'Prague')
3+ .addField('level', 1.12345)
4+ .time(DateTime.now().toUtc());
5+
6+ var writeService = client.getWriteService();
7+ await writeService.write(point).then((value) {
8+ print('Write completed');
9+ }).catchError((exception) {
10+ print(exception);
11+ });
You can’t perform that action at this time.
0 commit comments