Hi all,
I need your help with my current project. I am working on get_programme_info function to find the program info by search through in the database with program ids. I have got a problem with fetching the missing data from the database. I have got the program ids for BBC One that start from 3001 to 3008. For BBC Two I have the program ids that start from 3011 to 3016.
What I want to do is to count the 10 rows for each channel and if it counts less than 10, I want to create the variables
Here is what I want to store them in the list if it is count less than 10:
Example:
Count less than 10:
Can you please show me an example how I can use to count it to 10 and it is goes less than 10 for per channel then I want to create the variables for the string and value to store them in the self list?
Thanks in advance
I need your help with my current project. I am working on get_programme_info function to find the program info by search through in the database with program ids. I have got a problem with fetching the missing data from the database. I have got the program ids for BBC One that start from 3001 to 3008. For BBC Two I have the program ids that start from 3011 to 3016.
What I want to do is to count the 10 rows for each channel and if it counts less than 10, I want to create the variables
program_title and program_width to store them in the list. Here is what I want to store them in the list if it is count less than 10:
Example:
Count less than 10:
program_title = '[B]No Programme Information Available[/B]' program_width = 691 self.program_title.append(program_title) self.program_width.append(program_width)Count it to 10:
program_title = '[B]' + program_title + '[/B]' self.program_title.append(program_title) self.program_width.append(program_width)Here is the code:
def get_programme_info(self):
conn = database.connect('source.db')
cur = conn.cursor()
self.program_id = list(range(3001,3071)]
self.channelList = [101 BBC One S East, 102 BBC Two, 103 ITV, 104 Channel 4, 105 Channel 5, 106 Sky One, 106 Sky Living]
start_pos = 375 # indent for first program
count = 0
for program_id in self.program_id:
cur.execute('SELECT channel, title, start_date, stop_date, description FROM programs WHERE program_id=? LIMIT 10', [program_id])
programs = cur.fetchall()
count += 1
for ind, row in enumerate(programs):
channels = row[0]
program_title = row[1]
program_title = program_title.encode('utf-8', 'ignore')
program_title = '[B]' + program_title + '[/B]'
self.program_title.append(program_title)
self.program_width.append(program_width)I don't know how I can count it to 10 for per channel using with my current code.Can you please show me an example how I can use to count it to 10 and it is goes less than 10 for per channel then I want to create the variables for the string and value to store them in the self list?
Thanks in advance
