def _serialize_hstore(val):
 def esc(s, position):
  if ((position == 'value') and (s is None)):
   return 'NULL'
  elif isinstance(s, util.string_types):
   return ('"%s"' % s.replace('\\', '\\\\').replace('"', '\\"'))
  else:
   raise ValueError(('%r in %s position is not a string.' % (s, position)))
 return ', '.join((('%s=>%s' % (esc(k, 'key'), esc(v, 'value'))) for (k, v) in val.items()))

def _serialize_hstore ( val ) : def esc ( s , position ) : if ( ( position == 'value' ) and ( s is None ) ) : return 'NULL' elif isinstance ( s , util . string_types ) : return ( '"%s"' % s . replace ( '\\' , '\\\\' ) . replace ( '"' , '\\"' ) ) else : raise ValueError ( ( '%r in %s position is not a string.' % ( s , position ) ) ) return ', ' . join ( ( ( '%s=>%s' % ( esc ( k , 'key' ) , esc ( v , 'value' ) ) ) for ( k , v ) in val . items ( ) ) )
serialize a dictionary into an hstore literal .