1 changed files with 23 additions and 0 deletions
@ -0,0 +1,23 @@ |
|||||
|
import random |
||||
|
import mysql.connector #mysql-connector-python |
||||
|
import time |
||||
|
# http://172.25.2.58:8080 |
||||
|
db_connection = mysql.connector.connect( |
||||
|
host = "172.25.2.58", |
||||
|
user = "root", |
||||
|
password = "casaos", |
||||
|
database = "iot", |
||||
|
) |
||||
|
cursor = db_connection.cursor() |
||||
|
def odeslat_temp_user(username, senzor, value): |
||||
|
sql_query = "INSERT INTO iot_sp (dvojce, senzor, value, datetime) VALUES (%s, %s, %s, NOW())" |
||||
|
cursor.execute(sql_query,(username,senzor,value)) |
||||
|
db_connection.commit() |
||||
|
|
||||
|
usernameU = "admin+skrabanek" |
||||
|
senzorU = "DHT11(test)" |
||||
|
valueU = random.randint(23,30) |
||||
|
odeslat_temp_user(usernameU,senzorU,valueU) |
||||
|
|
||||
|
cursor.close() |
||||
|
db_connection.close() |
Loading…
Reference in new issue