added code to connect to MongoDB
This commit is contained in:
+8
-1
@@ -7,6 +7,7 @@ import pandas as pd
|
|||||||
import psycopg2
|
import psycopg2
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
|
from pymongo import MongoClient
|
||||||
|
|
||||||
|
|
||||||
class Database(object):
|
class Database(object):
|
||||||
@@ -222,4 +223,10 @@ def get_untranslated(dt):
|
|||||||
'id': int(df['id'][0]),
|
'id': int(df['id'][0]),
|
||||||
'content': str(df['content'][0])
|
'content': str(df['content'][0])
|
||||||
}
|
}
|
||||||
return val_dict
|
return val_dict
|
||||||
|
|
||||||
|
def connect_mongo(ip_addr: str = '192.168.1.2', db_name: str = 'twitter', collection_name: str = 'tweet'):
|
||||||
|
client = MongoClient(ip_addr)
|
||||||
|
db = client[db_name]
|
||||||
|
coll = db[collection_name]
|
||||||
|
return coll
|
||||||
|
|||||||
Reference in New Issue
Block a user