Updated server.py removing direct reference to DB_PWD

This commit is contained in:
CaiusX
2022-02-07 09:37:45 +02:00
parent 425d07c2f9
commit 35aca795de
+8 -1
View File
@@ -38,6 +38,13 @@ DISCONNECT_MESSAGE = "!DISCONNECT"
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(ADDR)
# Open most recent Configuration and grab DB_PWD as a python variable
with open('/home/pi/BirdNET-Pi/thisrun.txt', 'r') as f:
this_run = f.readlines()
db_pwd = str(str(str([i for i in this_run if i.startswith('DB_PWD')]).split('=')[1]).split('\\')[0])
def loadModel():
global INPUT_LAYER_INDEX
@@ -334,7 +341,7 @@ def handle_client(conn, addr):
connection = mysql.connector.connect(host='localhost',
database='birds',
user='birder',
password='databasepassword')
password=db_pwd)
cursor = connection.cursor()
mySql_insert_query = """INSERT INTO detections (Date, Time, Sci_Name, Com_Name, Confidence, Lat, Lon, Cutoff, Week, Sens, Overlap)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) """