This commit is contained in:
2024-11-17 01:39:09 +03:00
commit f6b300fc2c
17 changed files with 441 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import os
import motor
import motor.motor_asyncio
import pymongo
MONGO_HOST = os.getenv('MONGO_HOST', 'localhost')
MONGO_PASSWORD = os.getenv('MONGO_PASSWORD', 'password')
CONNECTION_STRING = f'mongodb://mongo:{MONGO_PASSWORD}@{MONGO_HOST}:27017/'
database: 'motor.MotorDatabase' = motor.motor_asyncio.AsyncIOMotorClient(CONNECTION_STRING).queues
def create_indexes():
client = pymongo.MongoClient(CONNECTION_STRING)
database = client.get_database('queues')
database.get_collection('tasks').create_index([
('queue', 1),
('available_from', 1),
])