no message

main
Sebastian Serfling 2023-08-17 11:56:49 +02:00
parent 342be255fa
commit 4515f4d52a
7 changed files with 60 additions and 0 deletions

16
.idea/sourcesync.xml Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="SourceSyncRemoteConfigurationsService"><![CDATA[{
"connections": [
{
"type": "ssh_configuration",
"name": "API-Server",
"hostname": "172.17.1.239",
"username": "root",
"remote_workspace_path": "/root",
"preserve_timestamps": true
}
],
"mainConnection": "API-Server"
}]]></component>
</project>

Binary file not shown.

View File

@ -0,0 +1,44 @@
import mysql.connector.locales.eng
import mysql.connector
import os
import time
os.environ['TZ'] = 'Europe/Berlin'
time.tzset()
def database(query,name,user):
# server.start()
mydb = mysql.connector.connect(
host="172.17.1.21",
port=3306,
user="root",
password="N53yBCswuawzBzS445VNAhWVMs3N59Gb9szEsrzXRBzarDqpdETpQeyt5v5CGe",
database="" + name,
auth_plugin='mysql_native_password',
)
mydb.connect()
cursor = mydb.cursor()
if "SELECT" in query:
if user:
cursor.execute(query, user)
return cursor.fetchone()
else:
cursor.execute(query, user)
return cursor.fetchall()
if "SHOW" in query:
cursor.execute(query)
return cursor.fetchall()
if "INSERT" in query:
cursor.execute(query,user)
mydb.commit()
if "UPDATE" in query:
cursor.execute(query,user)
mydb.commit()
mydb.close()
# mysql_connect.database("SELECT * from `Ping-Server` WHERE NAME='TNPTS01' ORDER BY time DESC LIMIT 1;")
server = database("SELECT DISTINCT NAME FROM `Ping-Server`","Stines-GmbH","")
for i in server:
print(i[0])
time = database(f"SELECT * from `Ping-Server` WHERE NAME='{i[0]}' ORDER BY time DESC LIMIT 1;","Stines-GmbH","")
print(time[0][0])