Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7670357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:48:16+00:00 2026-05-31T15:48:16+00:00

Am developing one using nodejs scraping and mysql. I want to store details into

  • 0

Am developing one using nodejs scraping and mysql. I want to store details into the mysql database. I have written the query it is saving sucessfully and it also checks for redundancy if we run the script again. If there is no data (empty table) in the table then, it is not checking for redundancy. All data is saving into the database.

The code what i have written to avoid redundency and insert into the table.

mysql.query(
    'select id, name from ' + product_details + ' where name = "'+$name+'"',                                                             
    function(err, result, fields) {
        if (err) throw err;
        else {
            var i;
            for (i in result) {
                var product = result[i];
                if(product.id>0){
                }
            }
            if(i==undefined){
                mysql.query('insert into '+ product_details +' (name) values ("' + $name + '")',
                    function selectCb(err, results, fields) {
                        if (err) throw err;
                        else {
                            console.log("inserted");
                    }
            });
        }
    }
});

Please help me to come out from this problem. Am new to nodejs scraping. Please help me. Thanks in advance.
** UPDATE **

Thank you user1027167. I tried your solution and i fixed the problem. But now mysql error occurs then script execution stops, but i want script to continue its execution by omitting (leaving) that detail to be saved in the database. How to do that please help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:48:17+00:00Added an answer on May 31, 2026 at 3:48 pm

    you have to fetch the error like this:

    mysql.query('insert into '+ product_details +' (name) values ("' + $name + '")',
        function errorhandler(err, results, fields) {
            if (err)
            {
                console.log("name is not unique");                
                // do something else
            }
        }
    });
    

    So you should not throw it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am developing one apps using sqlite.I created database in main Activity ,I created that
I'm developing one web application project using java for education industry.In this Admin have
I'm developing one web application, using PHP eclipse IDE. For an instance i want
What are profound advantages that one get when using COM for developing components over
I am developing an web application using php. One of the requirement is the
I`m developing an application using Spring WebFlow 2, Facelets and JSF. One of my
I'm developing a project using the MVVM pattern in WPF. One of the key
Background We are developing some in-house utilities using ASP.NET 2.0. One of which is
Hai every one I am developing an windows application in which i have to
I am developing one application using C# for processing MSWord files. My application gets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.