How to update value when working with SQlite database?

14 Ansichten (letzte 30 Tage)
I have a mysql lite database which is running via python. I am now trying to integrate control from MATLAB and read, write, and update values in the database from my MATLAB code.
Here is the link for sqlite database from Mathworks. https://www.mathworks.com/help/database/ug/sqlite.html
I already have my database configured via python (rows, colums, headers and so forth) and using the commands in the link above connect to the database and get my properties of the database and read the values also. I can also use the insert function if I want to add another row of data. The issue I am having is that how can I update a specific value in the database like I want to change row 2 column 2 value from lets says '0' to '1'? All the data is numerical and the headings are already defined.
If someone can guide me to which function I should be referring to simply UPDATE the value in the database?
Thanks.

Akzeptierte Antwort

Shiva Kalyan Diwakaruni
Shiva Kalyan Diwakaruni am 24 Nov. 2020
Hi,
exec(conn,sqlquery) performs database operations on an SQLite database file by executing the SQL statement SQL query for the SQLite connection conn using the MATLAB® interface to SQLite. For example, use this syntax to update the table using
example-
dbfile = fullfile(pwd,'tutorial.db')
conn = sqlite(dbfile,'create');
createInventoryTable =[‘UPDATE table’ ,’SET column_1 = new_value_1, column_2 = new_value_2’, ‘WHERE primary_key_value = current value’]
exec(conn,createInventoryTable)
Hope it helps.
References:
https://in.mathworks.com/help/database/ug/sqlite.exec.html
https://in.mathworks.com/help/database/ug/database.odbc.connection.update.html

Weitere Antworten (0)

Produkte


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by