OSDN Git Service

rename database_ids & some variables in order to understand easily
[amulettoolsmh4/main.git] / model / seedsholder.py
1 # -*- coding: utf-8 -*-
2
3 # Random Seedを保持するクラス
4 # 2013/12/04 written by kei9 
5
6 import db_supports
7
8 class SeedsHolder(object):
9     u""" Seed値を保持するクラス """
10     def __init__(self, seed_list):
11         u""" seed_list: list of seed
12         """
13         self.seed_set = set(seed_list)
14
15     def get_where_in_sql(self, remove_where=False):
16         u""" SQLのWhere文に変換する(IN句) """
17         if len(self.seed_set) >= 1:
18             uni_list = [u"{0}".format(x) for x in self.seed_set]
19             sql = u" {col} IN({in_phrase})".format(
20                     col=db_supports.SEED2_SKILL2_COL_SEED2,
21                     in_phrase=u",".join(uni_list))
22
23             if remove_where:
24                 return sql
25             else:
26                 return u" where" + sql
27         else:
28             return ""
29
30