예제 #1
0
    def count():
        Session = openSession()
        session = Session()

        result = session.query(func.count(CovidNewsDto.no)).one()[0]
        session.close()
        return result
예제 #2
0
    def count():
        Session = openSession()
        session = Session()

        result = session.query(func.count(
            EconomyExtractionWordDto.no)).one()[0]
        session.close()
        return result
예제 #3
0
    def save_data_bulk(datas):
        Session = openSession()
        session = Session()

        session.bulk_insert_mappings(CovidExtractionWordDto,
                                     datas.to_dict(orient='records'))

        session.commit()
        session.close()
예제 #4
0
    def find_all(self):

        Session = openSession()
        session = Session()

        result = session.query(CovidNewsDto).all()
        session.close()

        return result
예제 #5
0
    def find_all(self):

        Session = openSession()
        session = Session()

        result = session.query(CovidExtractionWordDto).all()
        session.close()

        return result
예제 #6
0
    def save_data_bulk(datas):
        Session = openSession()
        session = Session()

        session.bulk_insert_mappings(EconomyNewsDto,
                                     datas.to_dict(orient='records'))

        session.commit()
        session.close()
예제 #7
0
from collections import Counter
from com_blacktensor.ext.db import db, openSession
from sqlalchemy import func
import json
from flask import jsonify

from sqlalchemy import Column, Integer, String, Date
from com_blacktensor.cop.emo.model.emotion_kdd import EmotionKdd
from com_blacktensor.cop.emo.model.emotion_dto import EmotionDto, StockNewsDto
from com_blacktensor.cop.emo.model.emotion_dfo import EmotionDfo
from com_blacktensor.cop.emo.model.emotion_kdd import keyword

# import time
# import multiprocessing

Session = openSession()
session = Session()


class EmotionDao(EmotionDto):
    @staticmethod
    def bulk():
        emotion_dfo = EmotionDfo()
        dfo = emotion_dfo.data_pro(keyword)
        session.bulk_insert_mappings(EmotionDto, dfo.to_dict(orient='records'))
        session.commit()
        session.close()

    @staticmethod
    def save(emotion):
        session.add(emotion)