?
Solved

Threaded insert into MySQL database

Posted on 2011-09-06
4
Medium Priority
?
393 Views
Last Modified: 2012-05-12
I need some help with the following. I need to scan a directory with it's subdirectories in a thread (with a progress bar) and add all the ID3 tags into a mysql database. I only want to add new files to the database, so if certain directories where removed it must also be updated in the database.
0
Comment
Question by:DigitalNam
  • 2
4 Comments
 
LVL 3

Expert Comment

by:brezniczky
ID: 36491094
Hello,

You'lll need some kind of interthread synchronization, like TThread.Synchronize() to update the position of the progress bar.

You'll probably be able to insert the obtained data into the database from the background thread without a hassle, too, for instance, using ODBC driver via ADO (not ADOExpress). Though I am not experienced with that, it should be working, except if there are problems with the MySQL ODBC driver.

(At the time writing, I would not dare to state anything about the feasibility of the buit-in Windows file watching possibilities. Last time I had negative experiences with them, though infrequently.)

Are you interested in all of the steps you mentioned above, or only some specific ones?

0
 
LVL 1

Author Comment

by:DigitalNam
ID: 36491309
Hi brezniczky,I absolutely have no idea how to go about with the thread searching and progress bar part, the adding to the MySQL isn't a big issue for me, that I can do.
0
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 2000 total points
ID: 36492663
fwiw ...
how do you know before the start of the thread how items (folders) you will have ?

update progressbar from a thread > see my article
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/A_239-Displaying-progress-in-the-main-form-from-a-thread-in-Delphi.html

listing files into memo with thread and progressbar
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_26193383.html#32795255

for the database inserts, i guess you want the delta
here it depends on how many items you have
1: load the list from the database into memory and compare them
2: vice versa, save the list to the database (in a extra table) and compare the two tables (with stored procedure or query)
3: set table restrictions > unique key and ignore the insert duplicate errors
0
 
LVL 3

Expert Comment

by:brezniczky
ID: 36515969
Hello,

Should you stick to the concept of having a progress bar or even remaining time estimate on the UI during the process, maybe if you decompose the procedure into two steps - one for enumerating the files based on their extension (unknown length), and one for trying to read up the ID3's (from an a priori known number of files), you can achieve something similar to what you wanted.

I don't know if all your questions are answered already - do you have any more?
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question