code: def find_one_sql(table, filter, fields=None):
      '''
      >>> find_one_sql('tbl', {'foo': 10, 'bar': 'baz'})
      ('SELECT * FROM tbl WHERE bar=$1 AND foo=$2', ['baz', 10])
      >>> find_one_sql('tbl', {'id': 10}, fields=['foo', 'bar'])
      ('SELECT foo, bar FROM tbl WHERE id=$1', [10])
      '''
      keys, values = _split_dict(filter)
      fields = ', '.join(fields) if fields else '*'
      where = _pairs(keys)
      sql = 'SELECT {} FROM {} WHERE {}'.format(fields, table, where)
      return sql, valuef find_one_sql(table, filter, fields=None):
      '''
      >>> find_one_sql('tbl', {'foo': 10, 'bar': 'baz'})
      ('SELECT * FROM tbl WHERE bar=$1 AND foo=$2', ['baz', 10])
      >>> find_one_sql('tbl', {'id': 10}, fields=['foo', 'bar'])
      ('SELECT foo, bar FROM tbl WHERE id=$1', [10])
      '''
      keys, values = _split_dict(filter)
      fields = ', '.join(fields) if fields else '*'
      where = _pairs(keys)
      sql = 'SELECT {} FROM {} WHERE {}'.format(fields, table, where)
      return sql, values
docs: >>> find_one_sql('tbl', {'foo': 10, 'bar': 'baz'})
      ('SELECT * FROM tbl WHERE bar=$1 AND foo=$2', ['baz', 10])
      >>> find_one_sql('tbl', {'id': 10}, fields=['foo', 'bar'])
      ('SELECT foo, bar FROM tbl WHERE id=$1', [10])