def sqlselect(table, fields=['<STR_LIT:*>'], where=None, orderby=None, limit=None,<EOL>offset=None):
validate_name(table)<EOL>if fields != ['<STR_LIT:*>']:<EOL><INDENT>validate_names(fields)<EOL><DEDENT>fieldspart = '<STR_LIT:U+002CU+0020>'.join(fields)<EOL>sql = "<STR_LIT>".format(fieldspart, table)<EOL>values = []<EOL>if where:<EOL><INDENT>(whereclause, wherevalues) = sqlwhere(where)<EOL>if whereclause:<EOL><INDENT>sql = sql + "<STR_LIT>" + whereclause<EOL>values = wherevalues<EOL><DEDENT><DEDENT>if orderby:<EOL><INDENT>validate_names(orderby)<EOL>sql = sql + "<STR_LIT>" + '<STR_LIT:U+002CU+0020>'.join(orderby)<EOL><DEDENT>if limit:<EOL><INDENT>if not isinstance(limit, int):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>sql = sql + "<STR_LIT>".format(limit)<EOL><DEDENT>if offset:<EOL><INDENT>if not isinstance(offset, int):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>sql = sql + "<STR_LIT>".format(offset)<EOL><DEDENT>return (sql, values)<EOL>
Generates SQL select ...
    Returns (sql, params)

    >>> sqlselect('t')
    ('select * from t', [])
    >>> sqlselect('t', fields=['name', 'address'])
    ('select name, address from t', [])
    >>> sqlselect('t', where={'name': 'Toto', 'country': 'US'})
    ('select * from t where country=%s and name=%s', ['US', 'Toto'])
    >>> sqlselect('t', orderby=['lastname', 'firstname'])
    ('select * from t order by lastname, firstname', [])
    >>> sqlselect('t', limit=1)
    ('select * from t limit 1', [])
    >>> sqlselect('t', limit='yes')
    Traceback (most recent call last):
        ...
    ValueError: Limit parameter must be an int
    >>> sqlselect('t', offset=20)
    ('select * from t offset 20', [])
    >>> sqlselect('t', offset='yes')
    Traceback (most recent call last):
        ...
    ValueError: Offset parameter must be an int