Mongodb: skip to insert in db already exist file using python [duplicate]











up vote
0
down vote

favorite













This question already has an answer here:




  • MongoDB atomic “findOrCreate”: findOne, insert if nonexistent, but do not update

    4 answers



  • How to Ignore Duplicate Key Errors Safely Using insert_many

    1 answer




I download the lots of pdfs from the website and want to store in mongo db. but I already having some files in the same collection and want store there which is not there. i tried in python, but its not working.
I tried:



if db.ImportData.find(filename):
db.IEAImportData.insert_one({"Reported_date": reported_date, "FileID": str(pdfid), "LastModifiedDate": datetime.now().isoformat(), "IsProcessed": 0,})

else:
continue


Having "filename" is veriable in which all name of veriable is present.
So please guide me how should i do it










share|improve this question













marked as duplicate by Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 at 10:20


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Actually i already seen that question but couldn't understand what exactly they said.So can you please guide regarding my code. I am new in python
    – royal
    Nov 19 at 10:32















up vote
0
down vote

favorite













This question already has an answer here:




  • MongoDB atomic “findOrCreate”: findOne, insert if nonexistent, but do not update

    4 answers



  • How to Ignore Duplicate Key Errors Safely Using insert_many

    1 answer




I download the lots of pdfs from the website and want to store in mongo db. but I already having some files in the same collection and want store there which is not there. i tried in python, but its not working.
I tried:



if db.ImportData.find(filename):
db.IEAImportData.insert_one({"Reported_date": reported_date, "FileID": str(pdfid), "LastModifiedDate": datetime.now().isoformat(), "IsProcessed": 0,})

else:
continue


Having "filename" is veriable in which all name of veriable is present.
So please guide me how should i do it










share|improve this question













marked as duplicate by Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 at 10:20


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Actually i already seen that question but couldn't understand what exactly they said.So can you please guide regarding my code. I am new in python
    – royal
    Nov 19 at 10:32













up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:




  • MongoDB atomic “findOrCreate”: findOne, insert if nonexistent, but do not update

    4 answers



  • How to Ignore Duplicate Key Errors Safely Using insert_many

    1 answer




I download the lots of pdfs from the website and want to store in mongo db. but I already having some files in the same collection and want store there which is not there. i tried in python, but its not working.
I tried:



if db.ImportData.find(filename):
db.IEAImportData.insert_one({"Reported_date": reported_date, "FileID": str(pdfid), "LastModifiedDate": datetime.now().isoformat(), "IsProcessed": 0,})

else:
continue


Having "filename" is veriable in which all name of veriable is present.
So please guide me how should i do it










share|improve this question














This question already has an answer here:




  • MongoDB atomic “findOrCreate”: findOne, insert if nonexistent, but do not update

    4 answers



  • How to Ignore Duplicate Key Errors Safely Using insert_many

    1 answer




I download the lots of pdfs from the website and want to store in mongo db. but I already having some files in the same collection and want store there which is not there. i tried in python, but its not working.
I tried:



if db.ImportData.find(filename):
db.IEAImportData.insert_one({"Reported_date": reported_date, "FileID": str(pdfid), "LastModifiedDate": datetime.now().isoformat(), "IsProcessed": 0,})

else:
continue


Having "filename" is veriable in which all name of veriable is present.
So please guide me how should i do it





This question already has an answer here:




  • MongoDB atomic “findOrCreate”: findOne, insert if nonexistent, but do not update

    4 answers



  • How to Ignore Duplicate Key Errors Safely Using insert_many

    1 answer








python mongodb






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 19 at 10:18









royal

178




178




marked as duplicate by Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 at 10:20


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Neil Lunn mongodb
Users with the  mongodb badge can single-handedly close mongodb questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 19 at 10:20


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.














  • Actually i already seen that question but couldn't understand what exactly they said.So can you please guide regarding my code. I am new in python
    – royal
    Nov 19 at 10:32


















  • Actually i already seen that question but couldn't understand what exactly they said.So can you please guide regarding my code. I am new in python
    – royal
    Nov 19 at 10:32
















Actually i already seen that question but couldn't understand what exactly they said.So can you please guide regarding my code. I am new in python
– royal
Nov 19 at 10:32




Actually i already seen that question but couldn't understand what exactly they said.So can you please guide regarding my code. I am new in python
– royal
Nov 19 at 10:32

















active

oldest

votes






















active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes

Popular posts from this blog

Ottavio Pratesi

Tricia Helfer

15 giugno