How can I create a MySQL event to automatically add newly moved image files from my laptop?

I am trying to create a MySQL event so that I can automatically add files to my MySQL database. Basically, I'm starting the XAMPP server right now, so all the image files associated with my site / database are in the directory "C: \ Users \ Mus \ server \ htdocs \ images". Whenever I put an image file in this directory; I need this file to be loaded into the database automatically through this MySQL event that I am trying to create. This means that the database should continue to scan new files with an interval of 5 seconds, and if a new file has been added to the specified directory, a new record will be automatically created for the image (within the specified table) and at the same time, the image will be loaded into the same table in the database.

The SQL code I have used so far:

CREATE EVENT 'eventnov' ON SCHEDULE EVERY 5 SECOND STARTS '2015-10-27 00:00:00' ENDS '2015-10-28 00:00:00' DO INSERT INTO 'images_11_nov' SELECT NOW();

I understand that lines 5 and 6 are probably completely wrong, but I tried to investigate the existing problems and I was out of luck. I looked through the official MySQL documentation and, unfortunately, I can not find anything that matches my specific problem. I do not know the syntax for MySQL to perform all of the following actions in a single MySQL event:

  • Check the specified file directory (C: \ Users \ Mus \ server \ htdocs \ images) with the set time intervals of 5 seconds and IF there is a new move to this directory .... (number 2)
  • Automatically create an entry in the table "images_11_nov" as the owner of the place for the new image and ... (number 3)
  • ( "C:\Users\Mus\server\htdocs\images" ) "images_11_nov" .

- ? , , , .

  • 1: "images_11_nov" : "title" (varchar), "imgdata" (BLOB), "picid" (INT), "datetime" ( ).
  • 2: SQL Jayesh Dhandha, MySQL. :

CREATE EVENT 'eventnov' ON SCHEDULE EVERY 5 SECOND STARTS '2015-10-27 00:00:00' ENDS '2015-10-28 00:00:00' SELECT count(*) 'images_11_nov' system(ls C:\Users\Mus\server\htdocs\images | wc -l) system(ls -t | head -1) DO INSERT INTO 'images_11_nov';

+4
1

, . .

  • select count(*) table_name;
  • system(ls C:\Users\Mus\server\htdocs\images | wc -l)

  • , .

  • , .

  • 1, , .

  • system(ls -t | head -1)

ls -t , .

, .

,

0

Source: https://habr.com/ru/post/1613286/


All Articles