[storm] Questions about inserts

BožoDragojevič bozo.dragojevic at gmail.com
Fri Jun 13 12:55:17 BST 2008


James Henstridge <james at ...> writes:


> The storm.databases.mysql code passes "use_unicode=True,
> charset='utf8'" to the MySQLdb.connect() function, which should cause
> text data types to be returned as unicode.  If that isn't happening,
> it'd be good to investigate why.
> 

A new-enough MySQLDb does it for ASCII columns even if you do that:

>>> import MySQLdb
>>> MySQLdb.version_info
(1, 2, 2, 'final', 0)
>>> from md_foundation import *
>>> s=api.connect('mysql://joost@host/joost',DEBUG=1)
-- Connected to %s ('mysql://joost@host/joost',)
SELECT SchemaVersion.majorVersion, SchemaVersion.microVersion,
SchemaVersion.minorVersion, SchemaVersion.versionLabel FROM SchemaVersion ()
ROLLBACK ()
>>> from storm.locals import *;
>>> list(s.execute(SQL('select * from Organization limit 1')))
select * from Organization limit 1 ()
[(1L, '.unknown.organization', u'Unknown organisation')]

Note the lack of u before '.unknown.organization'

schema is like this:

>>> print list(s.execute(SQL('show create database joost')))[0][1]
show create database joost ()
CREATE DATABASE "joost" /*!40100 DEFAULT CHARACTER SET ascii COLLATE ascii_bin */
>>> print list(s.execute(SQL('show create table Organization')))[0][1]
show create table Organization ()
CREATE TABLE "Organization" (
  "id" int(11) unsigned NOT NULL auto_increment,
  "shortName" varchar(64) collate ascii_bin NOT NULL COMMENT 'human and
filesystem friendly unique stable name for an organization',
  "name" varchar(255) character set utf8 collate utf8_unicode_ci default NULL,
  PRIMARY KEY  ("id"),
  UNIQUE KEY "Organization_UniqueShortName" ("shortName"),
  KEY "Organization_nameIndex" ("name")
)


Bozzo




More information about the storm mailing list