Hi All,
I need to Delete a Document from the Doctype.it contains 78k records.But i want to delete only specific Entries around 3k(Dupicate) how can i achieve this???Can anyone help me out of this???
Hi All,
I need to Delete a Document from the Doctype.it contains 78k records.But i want to delete only specific Entries around 3k(Dupicate) how can i achieve this???Can anyone help me out of this???
By applying filter you can fetch your specific records and then delete it . From UI you can delete upto 500 records only at a time.
Use this filter section
Have you used System Console (/app/system-console/System Console)? You can do this in System Console with Python as Type. e.g.
for d in frappe.db.sql("""
select name from `tabSales Invoice` tsi
where exists (
select 1 from `tabSales Invoice` x
where x.posting_date < tsi.posting_date -- and whatever condition for duplicate
)
limit 1
"""):
print(d[0])
# frappe.delete_doc("Sales Invoice", d[0])
Make sure your query is correct.
Backup the db before trying, just in case.
No… Just copy the name from excel and use ‘where name in ('1','2'...)
’ in the sql stmt. That will be simpler
If you want to delete all rows at once, you can use the bench mariadb
command. This method allows bulk deletion directly from the database and is very fast. However, it is not safe because it bypasses all validations, permissions, and hooks defined in the DocType. The safest way is to delete via the DocType UI or bench console
or System Console (only 500 records can be deleted at a time)
thanks @Vipul_Kumar i have not done it before.let me check whether how can i delete by UI or Terminal
I don’t think so… you can do it in one go if you want… maybe add a frappe.db.commit after every 100 docs…
I think he means 500 from ui…
Don’t try deleting from db directly…you will need to clear child tables then