I would greatly appreciate any explanations or suggested
courses of action to get to the bottom of the problem described below.
If more information would be helpful I'd be glad to supply it. I'm
using Django 1.0.

I have a search application, in prototype stage, that makes use of
regular expressions entered by the user to search text values in a
table. The application is being developed using sqlite3 on a windows
machine. I transfer the files and load MySQL records
to a linux machine set up as a server. The application runs as
expected using MySQL and successfully searches the text values with
regular expressions, including those with special characters.

I wanted to compare performance on the linux machine if instead it
used sqlite3. For reasons I don't understand, the attempt to search,
with any regular expression, produces an exception:

--- begin exception traceback ---
Environment:

Request Method: GET
Request URL: http://dyndoc.dyndns.org:8000/mrdocs-search/results/
Django Version: 1.0-final-SVN-unknown
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.sessions',
 'proto.mr']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/var/lib/python-support/python2.5/django/core/handlers/base.py"
in get_response
  86.                 response = callback(request, *callback_args,
**callback_kwargs)
File "/home/django/project/proto/mr/views.py" in mrsearch
  111.     for p in mpageQS:
File "/var/lib/python-support/python2.5/django/db/models/query.py" in
_result_iter
  179.                 self._fill_cache()
File "/var/lib/python-support/python2.5/django/db/models/query.py" in
_fill_cache
  612.                     self._result_cache.append(self._iter.next
())
File "/var/lib/python-support/python2.5/django/db/models/query.py" in
iterator
  269.         for row in self.query.results_iter():
File "/var/lib/python-support/python2.5/django/db/models/sql/query.py"
in results_iter
  206.         for rows in self.execute_sql(MULTI):
File "/var/lib/python-support/python2.5/django/db/models/sql/query.py"
in execute_sql
  1700.         cursor.execute(sql, params)
File "/var/lib/python-support/python2.5/django/db/backends/util.py" in
execute
  19.             return self.cursor.execute(sql, params)
File "/var/lib/python-support/python2.5/django/db/backends/sqlite3/
base.py" in execute
  167.         return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /mrdocs-search/results/
Exception Value: user-defined function raised exception

--- end exception traceback ---

An excerpt of the code in my view that leads to this problem is the
ff:

    ...
    re_s = request.session.get('re_s', '')
    cs = request.session.get('cs', 0)

    pageQS = Page.objects.all()
    page_count = pageQS.count()
    if cs:
        qre_s = Q(line2__text__regex = re_s)
    else:
        qre_s = Q(line2__text__iregex = re_s)
    mpageQS = pageQS.filter(qre_s).distinct()

    fullpagelist = []
    mpgno = 0
    for p in mpageQS:
        fields = []
        mpgno += 1
    ...


(What I'm doing essentially is searching records in a table
whose content is lines from pages in documents: I want to
know, for a given regular expression pattern (re_s) and for
a specified case-sensitivity (cs) which pages contain lines
in which there is an re match. In the code above the re pattern
is retrieved from the session.)

I can duplicate the essence of the code above and run it manually
in the django shell: it works without problems using sqlite3.

I thought that the query or the params in the final traceback
statement:

    return Database.Cursor.execute(self, query, params)

might be mangled somehow. I enclosed that statment in base.py
with a try - except clause and raised my own Exception, to view
the SQL and the param: they were as expected (from looking at
connection.queries[-1]['sql'] while running the code manually in the
django shell).

I'm mystified at this point. Thanks for looking into this.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to