makaleChatbotu / mongoDb_2.py
yonkasoft's picture
Upload 11 files
b9ab29b verified
raw
history blame contribute delete
865 Bytes
from pymongo import MongoClient
import pandas as pd
#mongodb bağlantı ayarları
def get_mongodb(database_name='yedekDatabase',collection_name='yeni',host='localhost',port=27017):
"mongodb bağlantısı ve koleksiyon seçimi "
client=MongoClient(f'mongodb://{host}:{port}/')
db=client[database_name]
collection=db[collection_name]
return collection
#dataseti mongodb ye yükleme
def dataset_read():
data=pd.read_csv('C:\gitProjects\medium-articles\medium_articles_no_text.csv')
data_dict=data.to_dict("records")
source_collection=get_mongodb(database_name='yedekDatabase',collection_name='yeni') #çeviri için kullanılan kaynak koleksiyonu
source_collection.insert_many(data_dict)
print("kayıt mongodb ye yüklendi." )
return source_collection
if __name__=='__main__':
dataset_read()