ceys / django-tracking

Automatically exported from code.google.com/p/django-tracking
MIT License
0 stars 0 forks source link

DatabaseError. HINT: This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". #17

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'v got encoding error with database postgres:

Traceback (most recent call last):

 File "/var/www/movister.ru/web_site/django/core/handlers/base.py", line 80, in get_response
   response = middleware_method(request)

 File "/var/www/movister.ru/web_site/tracking/middleware.py", line 125, in process_request
   visitor.save()

 File "/var/www/movister.ru/web_site/django/db/models/base.py", line 435, in save
   self.save_base(using=using, force_insert=force_insert, force_update=force_update)

 File "/var/www/movister.ru/web_site/django/db/models/base.py", line 528, in save_base
   result = manager._insert(values, return_id=update_pk, using=using)

 File "/var/www/movister.ru/web_site/django/db/models/manager.py", line 195, in _insert
   return insert_query(self.model, values, **kwargs)

 File "/var/www/movister.ru/web_site/django/db/models/query.py", line 1479, in insert_query
   return query.get_compiler(using=using).execute_sql(return_id)

 File "/var/www/movister.ru/web_site/django/db/models/sql/compiler.py", line 783, in execute_sql
   cursor = super(SQLInsertCompiler, self).execute_sql(None)

 File "/var/www/movister.ru/web_site/django/db/models/sql/compiler.py", line 727, in execute_sql
   cursor.execute(sql, params)

 File "/var/www/movister.ru/web_site/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute
   return self.cursor.execute(query, args)

DatabaseError: неверная последовательность байт 
имя кодировки "UTF8": 0xeaf0ee
HINT:  This error can also happen if the byte sequence does not match the 
encoding expected by the server, which is controlled by "client_encoding".

I think the reason is: 

 'HTTP_REFERER': 'http://nova.rambler.ru/srch?query=%D0%BA%D1%80%D0%BE%D0%BB%D0%B8%D0%BA%D0%BE%D0%B2%2C%D1%88%D0%BD%D0%B8%D0%BF%D0%B5%D1%80%D1%81%D0%BE%D0%BD%2C%D0%B0%D0%BB%D0%BC%D0%B0%D0%B7%D0%BE%D0%B2...&old_q=\xea\xf0\xee\xeb\xe8\xea\xee\xe2,\xf8\xed\xe8\xf4\xe5\xf0\xf1\xee\xed,\xe0\xeb\xec\xe0\xe7\xee\xe2...',

I tried reproduce this error, but without success. 

Original issue reported on code.google.com by ramu...@gmail.com on 21 Oct 2010 at 1:16

GoogleCodeExporter commented 8 years ago
The error appears accidentally from time to time

Original comment by ramu...@gmail.com on 21 Oct 2010 at 1:17

GoogleCodeExporter commented 8 years ago
I haven't been able to reproduce this problem, but I've updated the middleware 
to clean up the HTTP_REFERER header and User Agent before inserting into the 
database to see if it helps.

Original comment by wheaties...@gmail.com on 27 Dec 2010 at 5:21