I want to query the following:
The attribute Unknown Hrs is Yes if the employee works on at least one project with NULL hours, and No otherwise.
And I do this by first making a list, theList containing all relevant social security numbers and consequently:
for i in theList:
unknown_hours=process_query("SELECT Distinct COUNT(*) FROM Works_On WHERE ISNULL(Hours) AND ESSN='%s'" %i)
temp.append(unknown_hours)
the trouble is that I get answers like 1L or 0L and I need them to be integers (for an algorithm). Any thoughts?
Regards Cenderze
asked Jul 31, 2013 at 13:51
Cenderze
1,2425 gold badges36 silver badges61 bronze badges
1 Answer 1
1L is just the long integer representation of the integer value 1:
>> type(1L)
<type 'long'>
>>> long(1)
1L
>>> int(1L)
1
Convert in Python:
int(unknown_hours)
Or in the database layer:
SELECT Distinct CAST(COUNT(*) AS UNSIGNED) FROM Works_On WHERE ISNULL(Hours) AND ESSN='%s'
answered Jul 31, 2013 at 15:11
Bryan
17.7k7 gold badges59 silver badges81 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Cenderze
Thank you! This is my first laboration in python so I forgot to mention that I used a list and int() was not possible. However with your answer I knew what to look for and eventually googled up the map function, so thank you! =)
default
int_unknown_hours = int(unknown_hours)?