Solved

Threaded insert into MySQL database

Posted on 2011-09-06
4
367 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 36

Accepted Solution

by:
Geert Gruwez earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now