Skip to content
Advertisement

Get data from database and write it back in again

I have written a function by reading an excel file and writing it to the database. This works!

Getting data from the database also works.

Where I get stuck is at the point that the function should read each row, calculate it and write the result back to the database.

I also want to find out how many rows were written in the database and then pass that number to the for-loop.

The first function is used to read the Excel data and write it to the database:

The second function is to read each row from the one column and calculate it row by row and then write it back into the database:

After I run my code, I get the error message:

c.execute(“SELECT * FROM zugversuch_probe_1 WHERE ID = ” + str(record_id)) mariadb.OperationalError: Unknown column ‘None’ in ‘where clause’

Unfortunately, I also have the problem that the ID in the database does not start again at 0 after I have deleted data, but continues to count.

Here is a screenshot of the database: Screenshot Database

Here is a screenshot of the Excel file: Screenshot Excel

Thank you in advance

Advertisement

Answer

yes it works!

it didn’t work for the reason that I forgot the brackets in conn.commit()

Here is my new code which i got from @vinzBad

Here is a Screenshot mariadb

Thank you for the help!

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement