Try something else
This commit is contained in:
		@@ -61,11 +61,11 @@ def main():
 | 
			
		||||
                # Build an INSERT statement based on the fields we have from the frame
 | 
			
		||||
                attrib_names = ', '.join('"%s"' % w for w in a.keys())
 | 
			
		||||
                attrib_values = ", ".join("?" * len(a.keys()))
 | 
			
		||||
                sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
 | 
			
		||||
                conn.commit()
 | 
			
		||||
                
 | 
			
		||||
                
 | 
			
		||||
                try:
 | 
			
		||||
                    # Insert data
 | 
			
		||||
                    sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")"
 | 
			
		||||
                    conn.execute(sql, list(a.values()))
 | 
			
		||||
 | 
			
		||||
                    # TODO update stations table here
 | 
			
		||||
@@ -75,18 +75,19 @@ def main():
 | 
			
		||||
                    # Build query
 | 
			
		||||
                    # "from" is wrappedin [] because it is a reserved word and using '' doesn't work.
 | 
			
		||||
                    # https://www.sqlite.org/lang_keywords.html
 | 
			
		||||
                    try:
 | 
			
		||||
                        station_update = "'"+a['from'] +"', '"+ str(a['created_unix']) +"', '1'"
 | 
			
		||||
                        query3 = "INSERT INTO stations ([from], last_heard_unix, count) \
 | 
			
		||||
                        VALUES("+station_update+") \
 | 
			
		||||
                        ON CONFLICT([from]) \
 | 
			
		||||
                        DO UPDATE SET count = count + 1;"
 | 
			
		||||
                        print(query3)
 | 
			
		||||
                        # Insert/update data
 | 
			
		||||
                        conn.execute(query3)
 | 
			
		||||
                        conn.commit()
 | 
			
		||||
                    except:
 | 
			
		||||
                        print("Stations table couldn't be updated.")
 | 
			
		||||
                    #try:
 | 
			
		||||
                    station_update = "'"+a['from'] +"', '"+ str(a['created_unix']) +"', '1'"
 | 
			
		||||
                    query3 = "INSERT INTO stations ([from], last_heard_unix, count) \
 | 
			
		||||
                    VALUES("+station_update+") \
 | 
			
		||||
                    ON CONFLICT([from]) \
 | 
			
		||||
                    DO UPDATE SET count = count + 1;"
 | 
			
		||||
                    print(query3)
 | 
			
		||||
                    # Insert/update data
 | 
			
		||||
                    conn.execute(query3)
 | 
			
		||||
                    
 | 
			
		||||
                    conn.commit()
 | 
			
		||||
                    #except:
 | 
			
		||||
                     #   print("Stations table couldn't be updated.")
 | 
			
		||||
 | 
			
		||||
                    # TODO remove packets that are older ('created') than a limit set in config.ini
 | 
			
		||||
                    # "5 minutes" also works
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user