@@ 95-121 (lines=27) @@ | ||
92 | ||
93 | return db |
|
94 | ||
95 | def _normalize(self, name, columns, points): |
|
96 | """Normalize data for the InfluxDB's data model.""" |
|
97 | ||
98 | for i, _ in enumerate(points): |
|
99 | # Supported type: |
|
100 | # https://docs.influxdata.com/influxdb/v1.5/write_protocols/line_protocol_reference/ |
|
101 | if points[i] is None: |
|
102 | # Ignore points with None value |
|
103 | del(points[i]) |
|
104 | del(columns[i]) |
|
105 | continue |
|
106 | try: |
|
107 | points[i] = float(points[i]) |
|
108 | except (TypeError, ValueError): |
|
109 | pass |
|
110 | else: |
|
111 | continue |
|
112 | try: |
|
113 | points[i] = str(points[i]) |
|
114 | except (TypeError, ValueError): |
|
115 | pass |
|
116 | else: |
|
117 | continue |
|
118 | ||
119 | return [{'measurement': name, |
|
120 | 'tags': self.parse_tags(self.tags), |
|
121 | 'fields': dict(zip(columns, points))}] |
|
122 | ||
123 | def export(self, name, columns, points): |
|
124 | """Write the points to the InfluxDB server.""" |
@@ 90-116 (lines=27) @@ | ||
87 | exponential_base=2)) |
|
88 | return write_client |
|
89 | ||
90 | def _normalize(self, name, columns, points): |
|
91 | """Normalize data for the InfluxDB's data model.""" |
|
92 | ||
93 | for i, _ in enumerate(points): |
|
94 | # Supported type: |
|
95 | # https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/ |
|
96 | if points[i] is None: |
|
97 | # Ignore points with None value |
|
98 | del(points[i]) |
|
99 | del(columns[i]) |
|
100 | continue |
|
101 | try: |
|
102 | points[i] = float(points[i]) |
|
103 | except (TypeError, ValueError): |
|
104 | pass |
|
105 | else: |
|
106 | continue |
|
107 | try: |
|
108 | points[i] = str(points[i]) |
|
109 | except (TypeError, ValueError): |
|
110 | pass |
|
111 | else: |
|
112 | continue |
|
113 | ||
114 | return [{'measurement': name, |
|
115 | 'tags': self.parse_tags(self.tags), |
|
116 | 'fields': dict(zip(columns, points))}] |
|
117 | ||
118 | def export(self, name, columns, points): |
|
119 | """Write the points to the InfluxDB server.""" |