etree, minidom unicode

N

n00b

hi,

i have a feew questions concnering unicode and utf-8 handling and
would appreciate any insights.

1) i got a xml document, utf-8, encoded and been trying to use etree
to parse and then commit to mysql db. using etree, everything i've
been extracting is return as a string except ascii char > 127, which
come back as a unicode. using minidom on the same document, however,
i get all unicode. is there a way to 'force' etree to use unicode?

2) i'm using mysql 5.x on * nix (mac, linux) and after much messing
around, have things
working, i.e. i have unicode from the (minidom) parser, set all mysql
and mysqldb attributes, i get <str> back from mysql. is that expected
behavior? #!/usr/bin/env python
# -*- coding: UTF-8 -*-
from xml.dom import minidom
import MySQLdb
import codecs
from onix_model_01 import *

db = MySQLdb.connect(host='localhost', user='root', passwd='',
db='lsi', charset='utf8')
cur = db.cursor()
#cur.execute('SET NAMES utf8')
#cur.execute('SET CHARACTER SET utf8')
cur.execute('SET character_set_connection=utf8')
cur.execute('SET character_set_server=utf8')
cur.execute('''SHOW VARIABLES LIKE 'char%'; ''')
....
.... now i'm getting the results back from mysql
....print q, type(q[0]), type(q[1]), type(q[2])
....print q[1], q[2]
....print repr(q[1]), repr(q[2])

so everything is coming back as it should, but i though i would get
the sql results back as unicode not str ... what gives?

finally, from a utf-8 perspective, is there any advantage using innodb
over myisam?

thx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top