Add delete functionality
This commit is contained in:
parent
78194437a9
commit
51d6738304
16
delete.py
Normal file
16
delete.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
from pymongo import MongoClient
|
||||||
|
from config import *
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
|
||||||
|
def delete(query_filter):
|
||||||
|
client = MongoClient(CONNECTION_STRING)
|
||||||
|
database = client[DATABASE]
|
||||||
|
collection = database[COLLECTION]
|
||||||
|
result = collection.delete_many(json.loads(query_filter))
|
||||||
|
print(result.raw_result)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
delete(sys.argv[1])
|
||||||
|
|
19
delete_tickets.py
Normal file
19
delete_tickets.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
from config import *
|
||||||
|
from delete import *
|
||||||
|
import sys
|
||||||
|
import base64
|
||||||
|
|
||||||
|
def delete_tickets():
|
||||||
|
from_date = str(input('From date [YYYY-MM-DD]: ') or "")
|
||||||
|
to_date = str(input('To date YYYY-MM-DD]: ') or "")
|
||||||
|
query_filter = json.dumps({
|
||||||
|
"businessDate": {'$gte': from_date+"T00:00:00", '$lte': to_date+"T00:00:00"}
|
||||||
|
})
|
||||||
|
print(query_filter)
|
||||||
|
delete(query_filter)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
delete_tickets()
|
||||||
|
|
Loading…
Reference in a new issue