2023-03-05 14:44:49 +00:00
|
|
|
import pymongo
|
|
|
|
|
|
|
|
myclient = pymongo.MongoClient("mongodb://root:example@localhost:27017/")
|
|
|
|
|
|
|
|
mydb = myclient["mydatabase"]
|
|
|
|
mycol = mydb["customers"]
|
|
|
|
|
|
|
|
mydict = {"text":"ahoj svet"}
|
|
|
|
|
|
|
|
x = mycol.insert_one(mydict)
|
2023-04-06 10:15:33 +00:00
|
|
|
|
|
|
|
def createdb():
|
|
|
|
myclient = pymongo.MongoClient(CONNECTION)
|
|
|
|
db=myclient[DBNAME]
|
|
|
|
linkcol = db["links"]
|
|
|
|
linkcol.create_index("url",unique=True)
|
|
|
|
linkcol.create_index("host")
|
|
|
|
contentcol = db["content"]
|
|
|
|
contentcol.create_index("url",unique=True)
|
|
|
|
#contentcol.create_index({"paragraph_checksums":1})
|
|
|
|
contentcol.create_index("host")
|
|
|
|
htmlcol = db["html"]
|
|
|
|
htmlcol.create_index("url")
|
|
|
|
domaincol = db["domains"]
|
|
|
|
domaincol.create_index("host",unique=True)
|