from db.mod_db import DataBase
from common.sql_utils import to_sql_in

class Preference:
    def __init__(self, db=None):
        if db is None:
            self.dataBase = DataBase()
        else:
            self.dataBase = db

    def select_sql(self,type):
        print("haha")
        return self.dataBase.fetch_all(
            'select * from check_name_preference_select  where select_meaning = "%s" and state = 1 limit 4' % type)
    def select_meaning(self):
        return self.dataBase.fetch_all("select DISTINCT(select_meaning) from check_name_preference_select limit 5")

    def select_word(self,word_list):
        return self.dataBase.fetch_all("select * from check_name_preference_select where select_word in (%s) " % to_sql_in(word_list))