def get_reactions(columns='all', n_results=20, write_db=False, **kwargs):
    """
    Get reactions from server

    Give key value strings as arguments
    """
    if write_db or columns == 'all':
        columns = all_columns['reactions']
    queries = {}
    for key, value in kwargs.items():
        key = map_column_names(key)
        if key == 'distinct':
            if value in [True, 'True', 'true']:
                queries.update({key: True})
                continue
        if isinstance(value, int) or isinstance(value, float):
            queries.update({key: value})
        else:
            queries.update({key: '{0}'.format(value)})

    subtables = []
    if write_db:
        subtables = ['reactionSystems', 'publication']
    else:
        subtables = []
    data = query(table='reactions', subtables=subtables,
                 columns=columns,
                 n_results=n_results, queries=queries)

    if not write_db:
        return data

    print('Writing result to Reactions.db')
    unique_ids = []
    for row in data['reactions']['edges']:
        with CathubSQLite('Reactions.db') as db:
            row = row['node']
            key_values = {}
            for key in all_columns['reactions']:
                v = row[key]
                # if isinstance(v, unicode):
                #    v = v.encode('utf-8')
                try:
                    v = json.loads(v)
                except BaseException:
                    pass
                key_values[convert(key)] = v
            ase_ids = {}
            energy_corrections = {}

            for row_rs in row['reactionSystems']:
                if row_rs['name'] == 'N/A':
                    continue
                ase_ids[row_rs['name']] = row_rs['aseId']
                energy_corrections[row_rs['name']] = row_rs['energyCorrection']

            if not ase_ids:
                ase_ids = None
                energy_corrections = None
            else:
                unique_ids += ase_ids.values()
            key_values['ase_ids'] = ase_ids
            key_values['energy_corrections'] = ase_ids

            # publications
            pub_key_values = {}
            row_p = row['publication']
            for key in all_columns['publications']:
                pub_key_values[convert(key)] = row_p[key]
            db.write_publication(pub_key_values)

            # reactions and reaction_systems
            id = db.check(key_values['chemical_composition'],
                          key_values['reaction_energy'])
            if id is None:
                id = db.write(key_values)
            else:
                db.update(id, key_values)

    if ase_ids is not None:
        # Ase structures
        with ase.db.connect('Reactions.db') as ase_db:
            con = ase_db.connection
            cur = con.cursor()
            cur.execute('SELECT unique_id from systems;')
            unique_ids0 = cur.fetchall()
            unique_ids0 = [un[0] for un in unique_ids0]
            unique_ids = [un for un in unique_ids if un not in unique_ids0]
            for unique_id in list(set(unique_ids)):
                # if ase_db.count('unique_id={}'.format(unique_id)) == 0:
                atomsrow = get_atomsrow_by_id(unique_id)
                ase_db.write(atomsrow)

    print('Writing complete!')

    return data