简体   繁体   中英

How do I create an MongoDB Atlas database using mongoengine

I'm using mongoengine in python and I cannot get it to create a database to connect to. I know how to use the connect function but I forgot how to create the DB or maybe they changed it?

I have all my collections set up as classes and I have a object with the.save() which causes this error. Object:

Product(
    name='Bitcoin',
    symbol='BTC',
    productId=1,
    amounts=['0.0005', '0.001', '0.002', '0.003', '0.005'],
    logo='btc.png',
    front='front.png',
    back='back.jpg',
    desc='p2p network'
).save()

Error:

mongoengine.errors.ValidationError: ValidationError (Product:None) (String value did not match validation regex 1.String value did not match validation regex

Databases get created automatically in MongoDB when you connect to it so this shouldn't be a problem.

The error you attached isn't related to that, that error suggest that something in the document that you try to save doesn't pass validation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM