it seems move existing code that use a rdms (sqlite, mysql, postgresql) to 
mongodb need an extra effort.
e.g.
*DAL connection from book*
>>> db = DAL('mongodb://user:password@localhost/connect_test')
*Error:*
...
OperationFailure: command SON([('authenticate', 1), ('user', u'user'), 
('nonce', u'7f46671524655a7d'), ('key', 
u'2be426ffba7c067a8a4ddb2a5e5056bf')]) on namespace connect_test.$cmd 
failed: auth failed
*Solution:*
1. without mongodb user and password
db = DAL('mongodb://localhost/connect_test')
or 
2. create mongodb user and password in terminal shell
cat <<EOL > userMongoDB.js
use connect_test
db.createUser(
  {
    user: "username",
    pwd: "password",
    roles: [ { role: "dbAdmin", db: "connect_test" },
             { role: "userAdmin", db: "connect_test" } ] 
  }
)
EOL
mongo test < userMongoDB.js

*Date not str*
>>> db.table0.insert(date0 = "2017-01-01", datetime0 = "2017-01-01 
00:00:00")
*Error:*
...
TypeError: combine() argument 1 must be datetime.date, not str
*Solution (strange that datetime field type didn't get affected by an error 
traceback):*
from datetime import datetime
db.table0.insert(date0 = datetime.strptime('2017-01-01', '%Y-%m-%d'), 
datetime0 = "2017-01-01 00:00:00")

*Iterselect*
>>> rows = db().iterselect(db.table0.ALL)
*Error:*
...
AttributeError: 'Mongo' object has no attribute 'iterselect'
*Solution:*
rows = db().select(db.table0.ALL)

not sure is there any difficulties i'll face during the moving, but 
grateful a lot things to learn from obstacles.

best regards,
stifan

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to