flask-mongo-app icon indicating copy to clipboard operation
flask-mongo-app copied to clipboard

How do I initialize the DB?

Open leoplusx opened this issue 4 years ago • 4 comments

Thanks for the great repository, Chris!

I'm getting an error when I try to sign up as a new user:

File "/var/www/convers.ai/python/flask-mongo-app/run.py", line 118, in register
    users = mongo.db.users
AttributeError: 'NoneType' object has no attribute 'users'

I've never worked with MongoDB before. But I suspect it's because my database is empty, i.e. has no columns?

Any command I need to run in order to initialize the database?

The DB itself seems to be working. I successfully ran this:

from pymongo import MongoClient
client = MongoClient(host = ["127.0.0.1:27017"])
client.server_info()

leoplusx avatar May 03 '21 15:05 leoplusx

Hi there. Thanks for your message. The live demo uses a MongoDB Atlas service. You might need to set up a free account at MongoDB Atlas to get access to your own database. It should work fine from there.

I have not set up a MongoDB server locally yet, so I’m not sure how to get that to work. As you say, it PyMongo’s MongoClient seemed to connect, I would have thought it was working.

I’ll try this later. Let me know how you get on if you have time.

Thanks again

Chris

On 3 May 2021, at 16:20, leobaumgardt @.***> wrote:

 Thanks for the great repository, Chris!

I'm getting an error when I try to sign up as a new user:

File "/var/www/convers.ai/python/flask-mongo-app/run.py", line 118, in register users = mongo.db.users AttributeError: 'NoneType' object has no attribute 'users' I've never worked with MongoDB before. But I suspect it's because my database is empty, i.e. has no columns?

Any command I need to run in order to initialize the database?

The DB itself seems to be working. I successfully ran this:

from pymongo import MongoClient client = MongoClient(host = ["127.0.0.1:27017"]) client.server_info() — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

chriswilson1982 avatar May 14 '21 07:05 chriswilson1982

Hi @leobaumgardt did you get this working? I'm just following up on previous issues. Thanks Chris

chriswilson1982 avatar Sep 20 '21 08:09 chriswilson1982

DB has connected with this config for me [DEFAULT] SECRET_KEY = secret123 SECURITY_PASSWORD_SALT = x123456 DATABASE_NAME = users MONGO_URI = mongodb://127.0.0.1:27017/users

jaggernaut007 avatar Jan 04 '22 08:01 jaggernaut007

Thanks for your update. Is it working as expected for you now?

On 4 Jan 2022, at 08:29, Jaggernaut @.***> wrote:

 DB has connected with this config for me [DEFAULT] SECRET_KEY = secret123 SECURITY_PASSWORD_SALT = x123456 DATABASE_NAME = users MONGO_URI = mongodb://127.0.0.1:27017/users

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

chriswilson1982 avatar Mar 21 '22 16:03 chriswilson1982