def literal_string(s):
 return ((u"'" + s.replace(u"'", u"''").replace(u'\x00', '')) + u"'")

def literal_string ( s ) : return ( ( u"'" + s . replace ( u"'" , u"''" ) . replace ( u'\x00' , '' ) ) + u"'" )
return s as a postgres literal string .