0

I do have a database named users but pymongo is looking for a db named as app is there any way to change to Pymongo connection method ?

this one is working if i crate a db named as app;

app = Flask(__name__)
mongo = PyMongo(app)

i want to connect like this but i do get an error for that ;

mongo = PyMongo('users')

2 Answers 2

1

I have found my answer;

client = MongoClient('localhost')
db = client['dbname']
collection = db.collection_name
Sign up to request clarification or add additional context in comments.

Comments

0
app = Flask(__name__)
app.config['MONGO_DBNAME'] = 'dbname'
mongo = PyMongo(app)

This allows you to use flask_pymongo, more info here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.