Пример #1
0
    def insertServices(self, filepath):
        connector = DBConnector()
        sql = (
            "INSERT INTO welfare_targets (service_id, disability_type, disability_grade, age_group, createdAt, updatedAt)"
            "VALUES (%s, %s, %s, %s, %s, %s) ")
        current_time = datetime.now()

        print('=' * 20 + 'start')
        rdr = self.openCsv(filepath)
        for column in rdr:
            data = (column[1], column[3], column[4], column[2], current_time,
                    current_time)
            print("-" * 20)
            print(data)
            connector.csv_into_db(sql, data)  # DB저장
            time.sleep(0.01)
        print('done')
Пример #2
0
    def insertAllServices(self, filepath):
        connector = DBConnector()
        # sql = ("INSERT INTO welfare_services (service_id, name, application_agency, application_method, url, desc, registedAt, createdAt, updatedAt) "
        #        "VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s) ")
        sql = (
            "INSERT INTO welfare_services (service_id, name, application_agency, application_method, url, registedAt, createdAt, updatedAt) "
            "VALUES (%s, %s, %s, %s, %s, %s, %s, %s) ")
        current_time = datetime.now()

        print('start')
        f = open(filepath, 'r', encoding='utf-8')  # csv 파일 오픈
        rdr = csv.reader(f)
        for column in rdr:
            if (column[0] != '#'):
                resigtedAt = datetime.strptime(column[8], '%Y-%m-%d')
                print(resigtedAt)
                data = (column[6], column[7], column[2], column[3], column[5],
                        resigtedAt, current_time, current_time)
                # data = (column[6], column[7], column[2], column[3], column[5], column[4], resigtedAt, current_time, current_time)
                print(data)
                connector.csv_into_db(sql, data)
                time.sleep(0.01)
        print('done')
    def __init__(self, parent=None):
        super().__init__(parent)

        self.setWindowTitle("SimpleTrial")
        self.setCentralWidget(QWidget(self))
        self.l_h = QHBoxLayout(self.centralWidget())

        # Initialize all components
        self.map_widget = MapWidget(self.centralWidget())
        self.chart_widget = ChartWidget(self.centralWidget())
        self.disease_widget = TreeWidget("disease", self.centralWidget())
        self.drug_widget = TreeWidget("drug", self.centralWidget())
        self.dialog_widget = DialogWidget(self.centralWidget())
        self.input_console = InputConsole(self.centralWidget())
        self.dialogflow = DialogFlow(self)
        # self.database_connector = DatabaseConnector(self)
        self.database_connector = DBConnector(self)

        # Arrange components in a layout
        self.l_h_left = QHBoxLayout()
        self.l_v_middle = QVBoxLayout()
        self.l_v_right = QVBoxLayout()

        self.l_h.addLayout(self.l_h_left, 1)
        self.l_h.addLayout(self.l_v_middle, 5)
        self.l_h.addLayout(self.l_v_right, 2)

        self.tab_widget_visualization = QTabWidget(self.centralWidget())
        self.central_stacked_widget = QStackedWidget(self.centralWidget())
        self.waiting_overlay = WaitingOverlay(self.central_stacked_widget)

        self.central_stacked_widget.addWidget(self.tab_widget_visualization)
        self.central_stacked_widget.addWidget(self.waiting_overlay)

        self.scroll_area = QScrollArea(self.centralWidget())
        self.scroll_area.setWidget(self.chart_widget)
        self.scroll_area.setWidgetResizable(True)
        self.tab_widget_visualization.addTab(self.scroll_area, 'Chart')
        self.tab_widget_visualization.addTab(self.map_widget, 'Map')
        self.l_v_middle.addWidget(self.central_stacked_widget)

        self.central_stacked_widget.setCurrentIndex(0)

        self.l_v_right.addWidget(self.dialog_widget)
        self.l_v_right.addWidget(self.input_console)

        self.tab_widget = QTabWidget(self.centralWidget())
        self.tab_widget.addTab(self.disease_widget, 'Disease')
        self.tab_widget.addTab(self.drug_widget, 'Drug')

        self.l_h_left.addWidget(self.tab_widget, 1)

        # Declare interaction between the components
        self.input_console.user_message_entered_signal.connect(
            self.dialogflow.process_user_message)

        # Highlight diseases and drugs for which we search in the database
        self.dialogflow.bot_request_signal.connect(
            self._on_bot_request_initiated)
        self.dialogflow.bot_request_signal.connect(
            self.disease_widget.highlight_bot_request)
        self.dialogflow.bot_request_signal.connect(
            self.drug_widget.highlight_bot_request)

        # Display conversation
        self.dialogflow.user_speak_signal.connect(
            self.dialog_widget.user_message_entered)
        self.dialogflow.bot_speak_signal.connect(
            self.dialog_widget.bot_message_entered)

        # Query SQL database
        self.dialogflow.bot_request_signal.connect(
            self.database_connector.process_bot_request)

        # Display query on the chart and on the map
        self.database_connector.bot_request_processed_signal.connect(
            self._on_bot_request_finished)
        self.database_connector.bot_request_processed_signal.connect(
            self.map_widget.display_processed_request)
        self.database_connector.bot_request_processed_signal.connect(
            self.chart_widget.display_processed_request)

        # Add some additional features
        # Double click on the disease and drug tree will insert text to the input_console
        self.disease_widget.element_selected.connect(self.input_console.insert)
        self.drug_widget.element_selected.connect(self.input_console.insert)

        # Add additional actions
        self.file_menu = self.menuBar().addMenu('File')

        self.log_window = LogWindow()
        self.open_log_action = QAction('Open Log')
        self.open_log_action.triggered.connect(self.log_window.show)
        self.file_menu.addAction(self.open_log_action)
        logger.set_log_window(self.log_window)

        self.hint_window = HintWindow()
        self.open_hints_action = QAction('Tips and Hints')
        self.open_hints_action.triggered.connect(self.hint_window.show)
        self.file_menu.addAction(self.open_hints_action)

        self.about_action = QAction('About')
        self.about_action.triggered.connect(self.show_about_dialog)
        self.file_menu.addAction(self.about_action)

        logger.log('Start application')
Пример #4
0
#!/usr/bin/python
from src.DBConnector import DBConnector
from src.db_refining.RelationBuilder import RelationBuilder
from src.db_refining.ViewBuilder import ViewBuilder

if __name__ == '__main__':

    with DBConnector('sqlite.db') as dbconnector:

        relationBuilder = RelationBuilder(dbconnector)
        relationBuilder.buildRelations()

        viewBuilder = ViewBuilder(dbconnector)
        viewBuilder.buildViews()

        dbconnector.commit()

Пример #5
0
    print(attribute_dict.get(int(id)))


def _get_movie_ranks(list, ids):
    return [list.index(str(id)) for id in ids]



if __name__ == '__main__':
    adjacencyGraphArray, adjacencyVectorArray, ppagerankVectorArray, ppagerankGraphArray, simrankVectorArray = _load_ranks()

    with (open('attributes_dict.txt', "rb")) as openfile:
        attribute_dict = pickle.load(openfile)


        with DBConnector() as dbconnector:
            print('-------pprGraph---------')
            print(_get_names_for(dbconnector, ppagerankGraphArray[:25]))
            print('--------adjGraph--------')
            print(_get_names_for(dbconnector, adjacencyGraphArray[:125]))
            print('---------adjVect-------')
            print(_get_names_for(dbconnector, adjacencyVectorArray[:25]))
            print('--------pprVect--------')
            print(_get_names_for(dbconnector, ppagerankVectorArray[:25]))
            print('--------simrankVector--------')
            print(_get_names_for(dbconnector, simrankVectorArray[:25]))
            print('----------------')

    print('\n \n \n Star Wars')
    movie_ids = [4,1330,1331,1332, 6578, 27378, 30898, 32790]
    movie_ids = [200000000 + id for id in movie_ids ]