Enable unicode

Chris Angelico rosuav at gmail.com
Tue Jan 28 04:32:27 EST 2014


On Tue, Jan 28, 2014 at 8:20 PM, Igor Korot <ikorot01 at gmail.com> wrote:
>>> So instead of using 'utf8' just use 'utf8mb4'?
>>
>> Yes, that's right. Unless utf8mb4 isn't supported, in which case try
>> utf8 and see if you can use the full range (something might be
>> translating it for you, which would probably be a good thing).
>
> So you mean just try it in the python  console and see if it works?

Yep. Play around with four categories of character: ASCII, Latin-1,
Basic Multilingual Plane, and Supplementary Multilingual Plane. They
correspond to codepoints <128, <256, <65536, and <1114112.

>>> Is it supported on all versions of MySQLDB?
>>
>> No idea! I don't use MySQLDB, so just give it a shot and see if it works.
>
> Problem is it might work on my machine, but the person I'm working
> with/for might have earlier version of the driver.
> That's actually why I asked on SO - is it supported on all versions of MySQLDB.

Try it on yours, try it on theirs; or dig through the docs to see when
it was added. Hard to say without knowing exactly what version your
client is using.

>> I strongly prefer PostgreSQL for anything where I actually care about
>> the data I'm storing. And yes, that's everything that I store. So I
>> don't use MySQL anywhere any more :)
>
> Hehe.
> Originally the software was written for SQLite.
> Then mySQL support was added and now the new script should be made
> based on the existing one and this new script will be used in a web
> based app - Django + jQuery/jQWidgets.
> The person is not a developer, rather have a management background so
> he is going with the market trend, which is currently mySQL for web
> app. ;-)
> I'd very much prefer to use SQLite as the data we use are text of the
> different length which is more suitable for SQLite. But....

Market trend is deceptive AND meaningless. Yes, there's a general
notion that low-grade web servers will give you Apache, MySQL, and
PHP, while not offering anything else; but that's like saying that a
dirt-cheap car comes with a radio and no CD player, ergo you should be
listening to the radio even in a car that has (or could have) a CD
player. The reason cheap web hosts offer MySQL is because lots of
people ask for it, and the reason people ask for it is because lots of
hosts offer it. There's no other reason. If you're the expert and he's
of management background, then it's your job to sell the technically
superior option despite his initial gut feeling... be an advocate, not
an automaton. :) And hopefully he'll respect your skills enough to
listen to your advice.

I don't have much experience with SQLite, but I would suspect that
"text of different lengths" should be able to be handled equally
cleanly by any database engine - at least the major ones. You may want
to look into whether you use VARCHAR, TEXT, or some other data type,
but it should work just fine.

ChrisA



More information about the Python-list mailing list