#5135: Unicode-branch merge broke insertion of binary data
-----------------------------------+----------------------------------------
Reporter:  [EMAIL PROTECTED]  |       Owner:  adrian             
  Status:  new                     |   Component:  Database wrapper   
 Version:  SVN                     |    Keywords:  binary blob unicode
   Stage:  Unreviewed              |   Has_patch:  0                  
-----------------------------------+----------------------------------------
 Django does not have a BinaryField, or BlobField or whatever you want to
 call it, which is a bit sad.
 In 0.96 and before it however worked to insert into blob fields with
 custom SQL though. In the SVN-release this is broken.
 
 An example from my code.
 info_hash is a blob field (mysql)
 
 def create_xbt_file(info_hash, timestamp):
   query = "INSERT INTO xbt_files (info_hash, mtime, ctime) VALUES (%s, %s,
 %s)"
   from django.db import connection
   cursor = connection.cursor()
   cursor.execute(query, [info_hash, timestamp, timestamp])
 
 This throws a nasty UnicodeDecodeError whenever a byte with a position
 between 45-50 (among others I guess) is in info_hash.
 
 If I bypass django completely using MySQLdb, then it works fine
 
 def create_xbt_file(info_hash, timestamp):
   import MySQLdb
   db = MySQLdb.connect("localhost", DATABASE_USER, DATABASE_PASSWORD,
 DATABASE_NAME)
   cursor = db.cursor()
   query = "INSERT INTO xbt_files (info_hash, mtime, ctime) VALUES (%s, %s,
 %s)"
   cursor.execute(query, [info_hash, timestamp, timestamp])
   db.close()

-- 
Ticket URL: <http://code.djangoproject.com/ticket/5135>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to