Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
co2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikita Yurishev
co2
Commits
a11333c5
Commit
a11333c5
authored
Oct 30, 2024
by
Nikita Yurishev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed influxConnection added env
parent
c7748a1d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
influxConnection.py
influxConnection.py
+9
-7
No files found.
influxConnection.py
View file @
a11333c5
from
influxdb
import
InfluxDBClient
import
os
from
dotenv
import
load_dotenv
load_dotenv
(
'creds.env'
)
import
time
class
InfluxConnection
:
def
__init__
(
self
):
#
Конфиги
self
.
INFLUXDB_URL
=
'http://influxdb.k8s.eterfund.ru'
self
.
INFLUXDB_DB
=
''
self
.
INFLUXDB_USER
=
''
self
.
INFLUXDB_PASSWORD
=
''
#
Получение конфигурации из переменных окружения
self
.
INFLUXDB_URL
=
os
.
getenv
(
'INFLUXDB_URL'
)
self
.
INFLUXDB_DB
=
os
.
getenv
(
'INFLUXDB_DB'
)
self
.
INFLUXDB_USER
=
os
.
getenv
(
'INFLUXDB_USER'
)
self
.
INFLUXDB_PASSWORD
=
os
.
getenv
(
'INFLUXDB_PASSWORD'
)
# Разделение URL на хост и порт
url_parts
=
self
.
INFLUXDB_URL
.
split
(
'://'
)[
1
]
.
split
(
':'
)
...
...
@@ -23,7 +27,6 @@ class InfluxConnection:
database
=
self
.
INFLUXDB_DB
)
def
write_data
(
self
,
sensor_id
,
values
):
json_body
=
[
{
...
...
@@ -43,4 +46,3 @@ class InfluxConnection:
def
__del__
(
self
):
self
.
client
.
close
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment