Beispiel #1
0
 def __get_tsquery(self, term, config, join_by, startswith, unaccent=True):
     operator = ' {} '.format(join_by)
     query = self.__startswith(term) if startswith else term
     query = adapt(operator.join(query))
     return ("to_tsquery('{}', {})".format(
         config,
         self.__unaccent(query) if unaccent else query
     ))
Beispiel #2
0
 def getquoted(self):
     # this is the important line: note how every object in the
     # list is adapted and then how getquoted() is called on it
     pobjs = [adapt(o) for o in self._seq]
     for obj in pobjs:
         if hasattr(obj, 'prepare'):
             obj.prepare(self._conn)
     qobjs = [o.getquoted() for o in pobjs]
     return b('(') + b(', ').join(qobjs) + b(')')
Beispiel #3
0
 def getquoted(self):
     # this is the important line: note how every object in the
     # list is adapted and then how getquoted() is called on it
     pobjs = [adapt(o) for o in self._seq]
     for obj in pobjs:
         if hasattr(obj, 'prepare'):
             obj.prepare(self._conn)
     qobjs = [str(o.getquoted()) for o in pobjs]
     return '(' + ', '.join(qobjs) + ')'
Beispiel #4
0
 def getquoted(self):
     # this is the important line: note how every object in the
     # list is adapted and then how getquoted() is called on it
     pobjs = [adapt(o) for o in self._seq]
     if self._conn is not None:
         for obj in pobjs:
             if hasattr(obj, 'prepare'):
                 obj.prepare(self._conn)
     qobjs = [o.getquoted() for o in pobjs]
     return b('(') + b(', ').join(qobjs) + b(')')
Beispiel #5
0
 def getquoted(self):
     # this is the important line: note how every object in the
     # list is adapted and then how getquoted() is called on it
     pobjs = [adapt(o) for o in self._seq]
     if self._conn is not None:
         for obj in pobjs:
             if hasattr(obj, "prepare"):
                 obj.prepare(self._conn)
     qobjs = [o.getquoted() for o in pobjs]
     return b"(" + b", ".join(qobjs) + b")"
Beispiel #6
0
def _makesafe(x):
    """
    Function that converts input into a PostgreSQL readable.
    """
    return adapt(x).getquoted().decode()
Beispiel #7
0
 def __quotes(word_list):
     return ['{}'.format(adapt(x.replace('\\', ''))) for x in word_list]