Substring Searching for Hebrew Text

10 views
Skip to first unread message

Art Zemon

unread,
Jul 8, 2016, 4:40:22 PM7/8/16
to Django users
Hello,

I have a column in a table that contains Hebrew text. I need to do a query with a LIKE clause on the Hebrew text. The query works if I execute the SQL directly, either in a SQL window of phpMyAdmin or in a command line mysql client. But I cannot get it to work within Django.

I tried Bible.objects.filter(hebrew_text__contains('דֶּשֶׁא') and I get nothing back.

I tried a raw query in a custom manager:

class BibleManager(models.Manager):
    def contains_hebrew_word(self, word='דֶּשֶׁא'):
        sql = """select sortkey, book, chapter, verse, hebrew_text
                 from bible_bible
                 where hebrew_text like '%%%s%%' """
        raw_query_set = self.raw(sql, [word])
        result_list = []
        for b in raw_query_set:
            result_list.append(b)
        return result_list

but I get this error:

django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'דֶּשֶׁא'%'' at line 3")

I am using 
  • Django 1.9
  • Python 3
  • mysqlclient 1.3.7
  • MySQL 5.5.49
Any ideas?

    -- Art Z.

Art Zemon

unread,
Jul 8, 2016, 4:42:21 PM7/8/16
to Django users
Never mind... this is s duplicate of a post that I made via email last night. The emailed one finally showed up. I guess it had been held for moderation.

-- Art Z.
Reply all
Reply to author
Forward
0 new messages