您的位置:首页 > 编程语言 > Python开发

查询中文按照拼音排序

2010-03-10 10:07 323 查看
查询中文按照拼音排序

 

select id,name from product_ringtone_album order by CONVERT( name USING gbk ) COLLATE gbk_chinese_ci ASC   

 

python连接MySql ,先安装python2Mysql库

 

  import MySQLdb

  conn = MySQLdb.connect (host = "localhost",

  user = "testuser",

  passwd = "testpass",

  db = "test")

  cursor = conn.cursor ()

  cursor.execute ("SELECT VERSION()")

  row = cursor.fetchone ()

  print "server version:", row[0]

  cursor.close ()

  conn.close ()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql python server user