Trying to convert from Raspberry, python to Arduino pragramming, is it possibel?

Hi

I have been looking on this for a while, but dont know if its possible, i send my python code and woundering if its possible to get the function on a ardunio bord insted.

import time
import datetime
import subprocess
import MySQLdb

execfile("/home/pi/tempLog/config.py")

cursor = connect.cursor()

cursor.execute("SELECT id, sensorid, type, location FROM sensors WHERE sys = %s AND node = %s AND active = 1", (sys_id, sys_node_id))

for row in cursor.fetchall():

        ts = time.time()
        timestamp = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
        id = row[0]
        sensor_id = row[1]
        sensor_type = row[2]
        location = row[3]

        output_value = subprocess.check_output("cat /mnt/2wire/" + sensor_id + "/" + sensor_type + "", shell=True)

        sensor_value = "{0:.1f}".format(float(output_value))

        cursor.execute("UPDATE sensors SET value=%s, lastupdate=%s WHERE id='%s'", (sensor_value, timestamp, id))

        print sensor_id + " | " + sensor_type + " | " + timestamp + " | " + sensor_value

        cursor.execute("UPDATE system SET sonsor_heartbeats=%s WHERE id='%s' AND node = %s", (timestamp, sys_id, sys_node_id))

        print "Hartbeat " + timestamp

        connect.commit()

print "Data updated"

row = cursor.fetchone()

cursor.close()
connect.close()

and you would run the MySQL database on the arduino as well?
or you'd want the arduino to query the DB that is hosted somewhere else?
how big is the data set?

May be you can explain what you want to achieve and what the system is, and then we can explore what makes sense.

It is always possible to translate program code, but whether the project will work depends on the specific hardware.

If the RPi hardware does something that the Arduino cannot, then no.

MySQL are running in the cloud!
The script lists active sensors from a databas and take the values and post it back.

so what would the arduino have to do ? (it's possible to send a request over IP to your server in the cloud and fetch data).

the arduino are going to connect to the database, get first sensor depending on sys and node id, get hardwareaddress and sensor type, run a command to extract the result from the 1-wire sensor, make a update of the line and insert a new line into another tabel, after that loop tthrue all posts in the tabel

It is possible but it’s likely that your arduino won’t have thousands different sensors connected ... so why wouldn’t the arduino just log whatever it captures ?

jenslu:
I have been looking on this for a while, but dont know if its possible, i send my python code and woundering if its possible to get the function on a ardunio bord insted.

Rather than think about "converting" you should write a very detailed description of what you want the Arduino to do and then create an Arduino program for that.

In the course of writing the description it should become clear whether all the actions can be done on the Arduino.

If you need WiFi you should also consider the ESP2866 boards such as the Wemos and NodeMCU and the ESP32. Somebody also makes a version of a Mega with an ESP8266 on the board.

...R