示例#1
0
 def set_analyzed(self, issue_id):
     params = {'analyzed': 1}
     conditions = {'id': [issue_id]}
     TransactionHandler.update(self,
                               table='issues',
                               params=params,
                               conditions=conditions)
示例#2
0
 def create(self, name, political_party, birthdate):
     values = {
         'name': name,
         'political_party': political_party,
         'birthdate': birthdate
     }
     TransactionHandler.insert(self, table='persons', params=values)
示例#3
0
 def create(self, name, description, established=0, disbanded=0):
     params = {
         'name': name,
         'description': description,
         'established': established,
         'disbanded': disbanded
     }
     print(params)
     TransactionHandler.insert(self, table='ministries', params=params)
示例#4
0
 def save_position(self, role, date_from, date_to, person_id, ministry_id,
                   cabinet_id):
     values = {
         'role': role,
         'date_from': date_from,
         'date_to': date_to,
         'person_id': person_id,
         'ministry_id': ministry_id,
         'cabinet_id': cabinet_id
     }
     TransactionHandler.insert(self, table='positions', params=values)
示例#5
0
 def create(self, title, type, number, file, date):
     # Analyzed is false by default when creating a new issue
     values = {
         'title': title,
         'type': type,
         'number': number,
         'file': file,
         'date': date,
         'analyzed': 0
     }
     TransactionHandler.insert(self, 'issues', values)
示例#6
0
    def find_most_common_role(self, conditions, person_name):
        conditions['person_name'] = [person_name]
        formatted_conditions = TransactionHandler.format_conditions(self, 'raw_signatures', conditions)
        query = ''' 
                    SELECT role,
                    COUNT(role) AS role_occurence 
                    FROM   raw_signatures
                    {conditions}
                    GROUP BY `role`
                    ORDER BY `role_occurence` DESC
                    LIMIT    1;
                '''.format(conditions=formatted_conditions)

        return TransactionHandler.execute_select_all(self, query=query)
示例#7
0
    def load_all_by_person_name(self, person_name, conditions = None):
        joins = {'persons' : ['INNER', 'signatures.person_id = persons.id']}

        if not conditions:
            conditions = {}

        conditions['persons.name'] = [person_name]
        return TransactionHandler.select_all(self, table='signatures', conditions=conditions, joins=joins)
示例#8
0
 def update(self, id, params):
     conditions = {'id': [id]}
     TransactionHandler.update(self,
                               table='persons',
                               params=params,
                               conditions=conditions)
示例#9
0
 def load_all_by_person_name(self, person_name):
     conditions = {'person_name': [person_name]}
     return TransactionHandler.select_all(self, table='raw_signatures', conditions=conditions)
示例#10
0
 def load_all(self, conditions=None):
     return TransactionHandler.select_all(self,
                                          table='persons',
                                          conditions=conditions)
示例#11
0
 def load_one(self, conditions=None):
     return TransactionHandler.select_one(self, table='raw_signatures', conditions=conditions)
示例#12
0
 def load_by_title(self, title):
     conditions = {'title' : [title]}
     return TransactionHandler.select_one(self, table='cabinets', conditions=conditions)
示例#13
0
 def create(self, title, description, date_from, date_to):
     params = {'title' : title, 'description' : description, 'date_from' : date_from,
               'date_to' : date_to}
     TransactionHandler.insert(self,table='cabinets',params=params)
示例#14
0
 def load_random(self, conditions=None):
     return TransactionHandler.select_random(self,
                                             table='issues',
                                             conditions=conditions)
示例#15
0
 def create_multiple(self, inserts):
     TransactionHandler.insert_multiple(self, 'raw_signatures', inserts)
示例#16
0
 def create(self, person_id, issue_id, data):
     params = {'person_id': person_id, 'issue_id': issue_id, 'data': data}
     TransactionHandler.insert(self, table='signatures', params=params)
示例#17
0
 def load_all(self, conditions=None, group_by=None, joins=None):
     return TransactionHandler.select_all(self,
                                          table='issues',
                                          conditions=conditions,
                                          joins=joins,
                                          group_by=group_by)
示例#18
0
 def create(self, person_name, role, issue_title, issue_date):
     params = {'person_name': person_name, 'role': role, 'issue_title': issue_title, 'issue_date' : issue_date}
     TransactionHandler.insert(self, table='raw_signatures', params=params)
示例#19
0
 def load_all(self):
     return TransactionHandler.select_all(self, 'ministries')
示例#20
0
 def load_by_name(self, name):
     conditions = {'name': [name]}
     return TransactionHandler.select_one(self,
                                          'ministries',
                                          conditions=conditions)
示例#21
0
 def load_position(self, conditions):
     return TransactionHandler.select_one(self,
                                          'positions',
                                          conditions=conditions)
示例#22
0
 def load_all(self, conditions=None, group_by=None):
     return TransactionHandler.select_all(self, table='raw_signatures', conditions=conditions, group_by=group_by)
示例#23
0
 def __init__(self, db_name='default'):
     TransactionHandler.__init__(self, db_name)
示例#24
0
 def update(self, params, conditions=None):
     TransactionHandler.update(self, 'raw_signatures', params, conditions)