Upgrade to influx2
This commit is contained in:
parent
18ce2b5399
commit
2c461ad4f7
3
docker_run.sh
Normal file
3
docker_run.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
docker run -p 8086:8086 \
|
||||||
|
-v $PWD:/var/lib/influxdb2 \
|
||||||
|
influxdb:2.0
|
@ -1,9 +1,16 @@
|
|||||||
from flask import Flask, request, render_template, redirect, url_for
|
from flask import Flask, request, render_template, redirect, url_for
|
||||||
from time import strftime
|
from time import strftime
|
||||||
import datetime
|
import datetime
|
||||||
|
import pendulum
|
||||||
|
from dotenv import dotenv_values
|
||||||
|
import influxdb_client
|
||||||
|
from influxdb_client.client.write_api import SYNCHRONOUS
|
||||||
|
|
||||||
|
|
||||||
|
config = dotenv_values(".env")
|
||||||
|
print(config)
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
from influxdb import InfluxDBClient
|
|
||||||
|
|
||||||
def db_main(host='localhost', port=8086):
|
def db_main(host='localhost', port=8086):
|
||||||
user = 'root'
|
user = 'root'
|
||||||
@ -16,9 +23,14 @@ def success():
|
|||||||
|
|
||||||
@app.route('/', methods=['GET', 'POST'])
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
def main_page():
|
def main_page():
|
||||||
client = InfluxDBClient('localhost', 8086, 'root', 'root', 'gas')
|
client = influxdb_client.InfluxDBClient(
|
||||||
query = 'select TOP(odometer, 5) from odyssey'
|
url=config['DB_URL'],
|
||||||
data = client.query(query)
|
token=config['DB_TOKEN'],
|
||||||
|
org=config['DB_ORG']
|
||||||
|
)
|
||||||
|
#query = 'select TOP(odometer, 5) from odyssey'
|
||||||
|
#data = client.query(query)
|
||||||
|
data = []
|
||||||
return render_template('index.html', data=data)
|
return render_template('index.html', data=data)
|
||||||
|
|
||||||
@app.route('/add_time', methods=['POST', 'GET'])
|
@app.route('/add_time', methods=['POST', 'GET'])
|
||||||
@ -62,9 +74,19 @@ def add_time():
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
timestamp = date + "T" + time + "Z"
|
||||||
client = InfluxDBClient('localhost', 8086, 'root', 'root', 'gas')
|
dt = pendulum.parse(timestamp)
|
||||||
|
print()
|
||||||
|
print(dt)
|
||||||
|
print()
|
||||||
|
client = influxdb_client.InfluxDBClient(
|
||||||
|
url=config['DB_URL'],
|
||||||
|
token=config['DB_TOKEN'],
|
||||||
|
org=config['DB_ORG']
|
||||||
|
)
|
||||||
|
write_api = client.write_api(write_options=SYNCHRONOUS)
|
||||||
|
p = influxdb_client.Point("2016_odyssey").time(timestamp).field("odometer", float(odometer))
|
||||||
|
write_api.write(bucket="gas", org=config['DB_ORG'], record=p)
|
||||||
print ("Submitting data to DB: {0}".format(json_body))
|
print ("Submitting data to DB: {0}".format(json_body))
|
||||||
client.write_points(json_body)
|
client.write_points(json_body)
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
wheel==0.29.0
|
certifi==2022.6.15
|
||||||
click==6.6
|
click==6.6
|
||||||
Flask==0.11.1
|
influxdb-client==1.30.0
|
||||||
Flask-WTF==0.13.1
|
|
||||||
influxdb==4.0.0
|
|
||||||
itsdangerous==0.24
|
itsdangerous==0.24
|
||||||
Jinja2==2.8
|
|
||||||
MarkupSafe==0.23
|
MarkupSafe==0.23
|
||||||
python-dateutil==2.6.0
|
pendulum==2.1.2
|
||||||
pytz==2016.10
|
pytz==2016.10
|
||||||
|
pytzdata==2020.1
|
||||||
requests==2.12.4
|
requests==2.12.4
|
||||||
|
Rx==3.2.0
|
||||||
six==1.10.0
|
six==1.10.0
|
||||||
|
urllib3==1.26.9
|
||||||
Werkzeug==0.11.11
|
Werkzeug==0.11.11
|
||||||
WTForms==2.1
|
WTForms==2.1
|
||||||
|
Loading…
Reference in New Issue
Block a user