To convert it uses the function eval
Ex:
  >>> lUnicodeData = u'[0,1,2]'
  >>> eval(lUnicodeData)
       [0, 1, 2]

 

Install mysql-workbench in Ubuntu

By CreativeSolutions


1. Open a terminal window.

2. Type in the following commands then hit Enter after each.

sudo add-apt-repository ppa:olivier-berten/misc
sudo apt-get update
sudo apt-get install mysql-workbench

3. To start the application, use this command.

    mysql-workbench &

 

MySQL query with left join and Date checking

Posted In: . By CreativeSolutions


SELECT p . *, l.lv_Date
FROM `people` AS p LEFT JOIN `leave` AS l
ON p.pl_Personid = l.lv_Tutor
WHERE p.pl_Usertype = 2 AND IF(l.lv_Date != NULL, l.lv_Date Not in ('2012-5-27'), NULL)

 







 The below code can be used to count the number of male/female in the Profile

 Profile.objects.values('gender').annotate(gener_count=Count('gender'))

 

Python - Convert unicde list to string

Posted In: . By CreativeSolutions


 import ast
 //data is the uncode list like u"[u'1', u'2', u'3', u'4']"
 s =  [ item.encode('ascii') for item in ast.literal_eval(data) ]
 val = ', '.join(s)

 If we try to convert to string using the join function it will not work and it will combine all the characters in the string. so we need to use the ast eval function with ascii encoding.