generated from kalanakt/Pyrogram-Telegram-Bot-Template
-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathdatabase.py
30 lines (21 loc) · 814 Bytes
/
database.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from pymongo import MongoClient
# Replace <username>, <password>, and <cluster-name> with your own values
client = MongoClient(
"mongodb+srv://ktu:[email protected]/?retryWrites=true&w=majority")
db = client.database
collection = db.utube_collection
def u_video(video_data, video):
post = {"video_data": video_data, "video": video}
result = collection.insert_one(post)
# This will print the ID of the inserted document
return result.inserted_id
def get_u_video(video_data):
query = {"video_data": video_data}
# Find documents with the given title
results = collection.find(query)
# Print the results
for result in results:
return result
def delete_u_video(video_data):
query = {"video_data": video_data}
collection.delete_one(query)