def insert_sql(table, data, returning='id'):
    '''
    >>> insert_sql('tbl', {'foo': 'bar', 'id': 1})
    ('INSERT INTO tbl (foo, id) VALUES ($1, $2) RETURNING id', ['bar', 1])

    >>> insert_sql('tbl', {'foo': 'bar', 'id': 1}, returning=None)
    ('INSERT INTO tbl (foo, id) VALUES ($1, $2)', ['bar', 1])

    >>> insert_sql('tbl', {'foo': 'bar', 'id': 1}, returning='pk')
    ('INSERT INTO tbl (foo, id) VALUES ($1, $2) RETURNING pk', ['bar', 1])
    '''
    keys, values = _split_dict(data)
    sql = 'INSERT INTO {} ({}) VALUES ({}){}'.format(
        table,
        ', '.join(keys),
        ', '.join(_placeholders(data)),
        ' RETURNING {}'.format(returning) if returning else '')
    return sql, values
>>> insert_sql('tbl', {'foo': 'bar', 'id': 1})
    ('INSERT INTO tbl (foo, id) VALUES ($1, $2) RETURNING id', ['bar', 1])

    >>> insert_sql('tbl', {'foo': 'bar', 'id': 1}, returning=None)
    ('INSERT INTO tbl (foo, id) VALUES ($1, $2)', ['bar', 1])

    >>> insert_sql('tbl', {'foo': 'bar', 'id': 1}, returning='pk')
    ('INSERT INTO tbl (foo, id) VALUES ($1, $2) RETURNING pk', ['bar', 1])