Solved

Threaded insert into MySQL database

Posted on 2011-09-06
4
375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 37

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mobile Keyboard covers the display of the TMemo 3 112
oracle global variables 4 80
Firemonkey webbrowser scrollbars ? 1 65
How to Get Images From Server using App Tethering 11 49
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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