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.

-- 
http://CheerfulCurmudgeon.com/ <http://cheerfulcurmudgeon.com/>

*"If I am not for myself, who is for me? And if I am only for myself, what
am I? And if not now, when?" Hillel*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN%2BRJV4Nr_c5NLRN%2B1CH9DVv%3DzvvUriJYvNyxZOh2pjXouqytw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to