I've been trying to move my collection to a different database, but it's giving me this every time I execute my move collections function:
pymongo.errors.OperationFailure: do not have permission to rename collections across dbs, full error: {'ok': 0, 'errmsg': 'do not have permission to rename collections across dbs', 'code': 8000, 'codeName': 'AtlasError'}
Here's my MongoDB Connection String:
mongodb://Makiyu:MyPasswordHereNotActuallyMyRealPassword@kigm-mongodatabase-shard-00-00.vv848.mongodb.net:27017,kigm-mongodatabase-shard-00-01.vv848.mongodb.net:27017,kigm-mongodatabase-shard-00-02.vv848.mongodb.net:27017/<dbname>?ssl=true&replicaSet=atlas-ug45u7-shard-0&authSource=admin&retryWrites=true&w=majority
I didn't use the SRV connection string URI because it keeps raising this error:
pymongo.errors.ConfigurationError: The DNS response does not contain an answer to the question: _mongodb._tcp.kigm-mongodatabase.vv848.mongodb.net. IN SRV
even after installing pymongo[srv].
The weirder part about everything is that I have admin permission (image below)
For moving collections, I used this answer (originally for PyMongo, I modified some stuff for moving multiple collections and for motor.)
Here's my code for moving the collections:
async def move_collections(self):
g_cols = await self.db.list_collection_names() # self.db is the `Guild` db
for i in g_cols:
await self.mongo.admin.command(bson.son.SON([('renameCollection',f'Guild.{i}'), ('to',f'BotData.{i}')]))
u_cols = await self.udb.list_collection_names() # self.udb is the `User` db
for i in u_cols: # and self.mongo is the AsyncIOMotorClient instance
await self.mongo.admin.command(bson.son.SON([('renameCollection',f'User.{i}'), ('to',f'BotData.{i}')]))