Submit templates for repl.it/templates here.

← Back to all posts
MongoDB Template
h
InvisibleOne (2931)

A helpful template for saving stuff in python with MongoDB.

Comments
hotnewtop
CodingCactus (4355)

hey this is really good except that you have your connection url out in the open which is a massive vulnerability as anyone could just use it to edit your database. You should use a .env, see https://docs.replit.com/repls/secrets-environment-variables

InvisibleOne (2931)

whoops, I meant to remove that as it was only there for testing purposes. @CodingCactus

CodingCactus (4355)

@InvisibleOne you should explain in the template how to use the .env otherwise people will just do exactly what you did and be vulnerable

Korbindev (134)

Traceback (most recent call last):
File "main.py", line 8, in <module>
client = pymongo.MongoClient(token)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pymongo/mongo_client.py", line 649, in init
seeds.update(uri_parser.split_hosts(entity, port))
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pymongo/uri_parser.py", line 358, in split_hosts
raise ConfigurationError("Empty host "
pymongo.errors.ConfigurationError: Empty host (or extra comma in host list).

IOP3 (854)

hMhmMMmmm....

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    client = pymongo.MongoClient(token)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pymongo/mongo_client.py", line 649, in __init__
    seeds.update(uri_parser.split_hosts(entity, port))
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/pymongo/uri_parser.py", line 358, in split_hosts
    raise ConfigurationError("Empty host "
pymongo.errors.ConfigurationError: Empty host (or extra comma in host list).
InvisibleOne (2931)

that's because you need to put the access link from your database where token is. @IcynDevz