Programming => Databases => Topic started by: Noobie on July 21, 2021, 09:30:04 am
Title: Writing text file to Mysql
Post by: Noobie on July 21, 2021, 09:30:04 am
I have a mysql db where is table with five columns, like id, machine 1..3 and log where is 1 to 15 rows. All machines have state from 0 to 3 and common log file which is updated every 60-70 seconds.
How do I write a log file to specific column like..
Title: Re: Writing text file to Mysql
Post by: dseligo on July 22, 2021, 10:01:22 am
There is a couple of ways to accomplish this.
I.) You can write log in each row like below. You probably can't have primary key in this way, or you could add 'rowno' or similar as autoincrement primary key.
II.) You could write each 'id' in one separate row (as you suggested it), but 'log' column should be big enough to store maximum possible 'log' values (plus separators).
III.) Add another table. In the parent table you store 'm1', 'm2' and 'm3'. In the child table you store 'log' values. Column 'id' is link between tables.