here is my so far code...
main.py file
import pymongo
from kivymd.app import MDApp
from kivy.lang import Builder
from kivy.uix.floatlayout import FloatLayout
cluster = pymongo.MongoClient("mongodb+srv://NAVIN:password@cluster0.bpj.mongodb.net/myFirstDatabase?retryWrites"
"=true&w=majority")
mydb = cluster["test"]
mycoll = mydb["USER_NAME"]
post = {'num': 0}
class demo_mongo(FloatLayout):
pass
class my_first(MDApp):
def build(self):
return Builder.load_file("label.kv")
def click(self):
post['num'] = post['num'] + 1
mycoll.insert_one(post)
my_first().run()
print("done")
label.kv
MDFloatLayout: MDBoxLayout: Button: text:"G A M E S" size_hint:.66,.065 pos_hint:{"center_x":.5,"center_y":.60} background_color: 1,1,1,1 on_release:app.click()
wheneever a button is pressed a increment in mongodb data some in an label, just someting like a [LIKE BUTTON] in some application when some one click number of click shows in label
BUT SOME HOW MY CODE CAN NOT WORK LIKE THAT ITS CREATE NEW _ID IN MONGODB FOR HOLDING DATA
source https://stackoverflow.com/questions/72235038/how-can-we-increment-number-data-in-mongodb-by-using-python
Comments
Post a Comment