def format_db_selection(selection, engine=None):
<EOL>if selection is None:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>selections = []<EOL>for col, op_, value in parse_column_filters(selection):<EOL><INDENT>if engine and engine.name == '<STR_LIT>':<EOL><INDENT>col = '<STR_LIT>' % col<EOL><DEDENT>try:<EOL><INDENT>opstr = [key for key in OPERATORS if OPERATORS[key] is op_][<NUM_LIT:0>]<EOL><DEDENT>except KeyError:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>" % op_)<EOL><DEDENT>selections.append('<STR_LIT>'.format(col, opstr, value))<EOL><DEDENT>if selections:<EOL><INDENT>return '<STR_LIT>' % '<STR_LIT>'.join(selections)<EOL><DEDENT>return '<STR_LIT>'<EOL>
Format a column filter selection as a SQL database WHERE string