[Answered ]-Django syncdb behaving strangely with unicode strings

0👍

Well, it seems like my sqlite3 module was acting up. I ended up reinstalling Red Hat’s sqlite-devel package, recompiling Python 2.7.3, and then updating the executable in the virtualenv.

Seems to be working well now. Now when I run django’s get_table_list() query, I get the following:

>>> import sqlite3
>>> conn = sqlite3.connect('/path/to/sqlite/file')
>>> curs = conn.cursor()
>>> curs.execute("""
... SELECT name FROM sqlite_master
... WHERE type='table' AND NOT name='sqlite_sequence'
... ORDER BY name""")
<sqlite3.Cursor object at 0xb7774ca0>
>>> curs.fetchall()
[(u'my_app_mytable',), (u'my_app_myothertable',)]

I made no changes to the sqlite file itself, so it seems this was an issue either with the sqlite3 module, and/or my Python 2.7.3 installation.

👤Nitzle

2👍

I encountered a similar problem, same syncdb command executed successfully on one environment and not on other with same database imports and model.
Changing call_command(syncdb) to os.system('python ' + |path|, 'manage.py syncdb')) solved it for me.

Hope it helps others.

👤lmc

0👍

Your text editor has decided to save the file as UTF-16LE. Put the following at the top of your source files, below the shebang:

# -*- coding: utf-16le -*-

Leave a comment