from pymongo import MongoClient import requests import os from pymongo import MongoClient MONGO_URI = os.getenv('MONGO_URI', 'mongodb://localhost:27017') REFERENCE_DB = os.getenv('REFERENCE_DB', 'EgitimDatabase') INPUT_DB = os.getenv('INPUT_DB', 'InputDatabase') def connect_to_mongodb(): """MongoDB'ye bağlan.""" client = MongoClient(MONGO_URI) return client def get_reference_data(): """Reference database'den verileri al.""" client = connect_to_mongodb() db = client[REFERENCE_DB] collection = db['test'] # Kendi koleksiyon isminizi buraya yazın data = collection.find({}, {"title": 1, "keywords": 1, "text": 1, "_id": 0}) return list(data) def insert_data_into_input_db(data): """Input database'e veri ekle.""" client = connect_to_mongodb() db = client[INPUT_DB] collection = db['input'] # Kendi koleksiyon isminizi buraya yazın collection.insert_many(data) def get_user_input(): """Kullanıcıdan veri al.""" #yöntemi eklemem gerek user_input = [ {"title": "Sample Title", "keywords": ["keyword1", "keyword2","keyword3","keyword4","keyword5"], "text": "Sample text."} ] return user_input def main(): """Ana fonksiyon.""" client = connect_to_mongodb() reference_data = get_reference_data() user_data = get_user_input() insert_data_into_input_db(user_data) client.close() if __name__ == "__main__": main()