Jump to content

Recommended Posts

Hello guys, may be my question is simple to you but for me its something I need to know :)

 

I have a big script. The main purpose of script is to scrap data and store in mysql.

 

Basically it can be structured like this :

 

# Database Connect

# Query

# Scrap

# Query

# Scrap

# Query

# Disconnect

 

What I want to know is what is best performance wise ? Opening a new connection for each query and closing after its completion ? Or open the connection once and let the script complete and then close it finally. Since scraping part will take considerable time may be 1-2 minutes.

 

Please reply that :)

I'd have to agree with cags - open, run your queries, then close. Is there no way to do

 

Query

Query

Query

Scrap

Scrap

Scrap

 

?

 

 

Thats the real problem the steps cant be serialize as you stated otherwise I would have done that :)

 

Oke I would open connection only when needed :)

 

Thanks :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.