Skip to content

Instantly share code, notes, and snippets.

@djotaku
Created August 15, 2022 23:34
Show Gist options
  • Save djotaku/e1c8ff97123b9c9d0c880fa810d21303 to your computer and use it in GitHub Desktop.
Save djotaku/e1c8ff97123b9c9d0c880fa810d21303 to your computer and use it in GitHub Desktop.
load_data.py error
Importing users ...
Traceback (most recent call last):
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib/python3.10/site-packages/beanie/odm/documents.py", line 403, in save
return await self.replace(session=session, **kwargs)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib/python3.10/site-packages/beanie/odm/actions.py", line 212, in wrapper
result = await f(self, *args, skip_actions=skip_actions, **kwargs)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib/python3.10/site-packages/beanie/odm/utils/state.py", line 39, in wrapper
result = await f(self, *args, **kwargs)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib/python3.10/site-packages/beanie/odm/utils/state.py", line 50, in wrapper
result = await f(self, *args, **kwargs)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib/python3.10/site-packages/beanie/odm/utils/self_validation.py", line 12, in wrapper
return await f(self, *args, **kwargs)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib/python3.10/site-packages/beanie/odm/documents.py", line 321, in replace
raise ValueError("Document must have an id")
ValueError: Document must have an id
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/exercises/Day_04/09-beanie-querying/bin/load_data.py", line 286, in <module>
asyncio.run(main())
File "/usr/lib64/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib64/python3.10/asyncio/base_events.py", line 646, in run_until_complete
return future.result()
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/exercises/Day_04/09-beanie-querying/bin/load_data.py", line 40, in main
await do_user_import(users)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/exercises/Day_04/09-beanie-querying/bin/load_data.py", line 58, in do_user_import
await user.save()
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib/python3.10/site-packages/beanie/odm/documents.py", line 405, in save
return await self.insert(session=session, **kwargs)
File "/usr/lib64/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib64/python3.10/site-packages/pymongo/collection.py", line 621, in insert_one
self._insert_one(
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib64/python3.10/site-packages/pymongo/collection.py", line 562, in _insert_one
self.__database.client._retryable_write(acknowledged, _insert_command, session)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib64/python3.10/site-packages/pymongo/mongo_client.py", line 1448, in _retryable_write
return self._retry_with_session(retryable, func, s, None)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib64/python3.10/site-packages/pymongo/mongo_client.py", line 1321, in _retry_with_session
return self._retry_internal(retryable, func, session, bulk)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib64/python3.10/site-packages/pymongo/_csot.py", line 105, in csot_wrapper
return func(self, *args, **kwargs)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib64/python3.10/site-packages/pymongo/mongo_client.py", line 1362, in _retry_internal
return func(session, sock_info, retryable)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib64/python3.10/site-packages/pymongo/collection.py", line 560, in _insert_command
_check_write_command_response(result)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib64/python3.10/site-packages/pymongo/helpers.py", line 217, in _check_write_command_response
_raise_last_write_error(write_errors)
File "/home/ermesa/Programming Projects/Python/fastapi_mongodb_class_notes/venv/lib64/python3.10/site-packages/pymongo/helpers.py", line 189, in _raise_last_write_error
raise DuplicateKeyError(error.get("errmsg"), 11000, error)
pymongo.errors.DuplicateKeyError: E11000 duplicate key error collection: pypi.users index: email_ascend dup key: { email: "miurahr@linux.com" }, full error: {'index': 0, 'code': 11000, 'keyPattern': {'email': 1}, 'keyValue': {'email': 'miurahr@linux.com'}, 'errmsg': 'E11000 duplicate key error collection: pypi.users index: email_ascend dup key: { email: "miurahr@linux.com" }'}
Process finished with exit code 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment