mirror of
https://github.com/open5gs/open5gs.git
synced 2026-04-29 11:59:32 +00:00
rename utils to mongodb
This commit is contained in:
parent
964e7ecebd
commit
a6e3affbec
2 changed files with 0 additions and 0 deletions
55
support/mongodb/python/NextEPC.py
Normal file
55
support/mongodb/python/NextEPC.py
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import mongo
|
||||
import pymongo
|
||||
import random
|
||||
import bson
|
||||
|
||||
class NextEPC:
|
||||
def __init__(self, server, port):
|
||||
self.server = server
|
||||
self.port = port
|
||||
|
||||
|
||||
def GetSubscribers(self):
|
||||
myclient = pymongo.MongoClient("mongodb://" + str(self.server) + ":" + str(self.port) + "/")
|
||||
mydb = myclient["nextepc"]
|
||||
mycol = mydb["subscribers"]
|
||||
subs_list = []
|
||||
for x in mycol.find():
|
||||
print(x)
|
||||
subs_list.append(x)
|
||||
pass
|
||||
|
||||
return subs_list
|
||||
|
||||
def GetSubscriber(self, imsi):
|
||||
myclient = pymongo.MongoClient("mongodb://" + str(self.server) + ":" + str(self.port) + "/")
|
||||
mydb = myclient["nextepc"]
|
||||
mycol = mydb["subscribers"]
|
||||
myquery = { "imsi": str(imsi)}
|
||||
mydoc = mycol.find(myquery)
|
||||
for x in mydoc:
|
||||
print(x)
|
||||
return x
|
||||
|
||||
|
||||
def AddSubscriber(self, sub_data):
|
||||
|
||||
myclient = pymongo.MongoClient("mongodb://" + str(self.server) + ":" + str(self.port) + "/")
|
||||
mydb = myclient["nextepc"]
|
||||
mycol = mydb["subscribers"]
|
||||
|
||||
x = mycol.insert_one(sub_data)
|
||||
print("Added subscriber with Inserted ID : " + str(x.inserted_id))
|
||||
return x.inserted_id
|
||||
|
||||
|
||||
def DeleteSubscriber(self, imsi):
|
||||
myclient = pymongo.MongoClient("mongodb://" + str(self.server) + ":" + str(self.port) + "/")
|
||||
mydb = myclient["nextepc"]
|
||||
mycol = mydb["subscribers"]
|
||||
myquery = { "imsi": str(imsi)}
|
||||
x = mycol.delete_many(myquery)
|
||||
print(x.deleted_count, " subscribers deleted.")
|
||||
return x.deleted_count
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue