Oct-18-2016, 10:15 PM
Hi folks,
I am writing a code to allow me to input the data into the sqlite database.
Here is what I am using:
I have got no idea how I could find the data using with the variable to find a matched string in a database before I could replace with the strings that I want to replace. I want to find the string of 3001 to replace it with a empty string, then find the string 3002 to replace it with 3001, find the string 3003 to replace it with 3004, find the string 3003 to replace it with 3004, find the string 3005 to replace it with 3004 and so on until I insert the 3010 data in a new cell just after the id "3009".
Just like this:
http://i.imgur.com/ZUK6ATG.jpg
I have not write a code for the update in a database, so I have got no idea how to search for the strings that I want to find them in a database before I could replace them with the strings that I want to replace.
Do you know how I could find the string in a database using the variable program_id to replace them with each of the strings that start from 3002 to 3010 to replace it with 3001 to 3009 and insert 3010 after the 3009 data??
Any advice will be greatly appreciated.
Thanks in advance
I am writing a code to allow me to input the data into the sqlite database.
Here is what I am using:
#store the id and width of buttons in a database for title, channel_name, start_time, stop_time, category, prog_width in izip_longest(title_list, channelsList, start_time_list, stop_time_list, categoryList, program_width, fillvalue=''): if channel_name != channel_namelast: # next channel countbut = 0 # we will allow for 10 buttons per channel (0 to 9 from button_id list) if countbut < 10 and countbc < 70: #ie we are adding a button_id here buttonadd = program_id[countbc] # get the buttonid from the list countbc = countbc + 1 countbut = countbut + 1 else: buttonadd = "" #put in a blank print "you have added no string in a database" cur.execute("INSERT INTO programs(channel, title, start_date, stop_date, category, program_id)" + " VALUES(?, ?, ?, ?, ?, ?)", [channel_name, title, start_time, stop_time, category, buttonadd]) channel_namelast = channel_nameI got the list of button ids when I am adding the list of button objects. I am using the variable called program_id to get the button id, so I could search them in a database to find a matched string.
I have got no idea how I could find the data using with the variable to find a matched string in a database before I could replace with the strings that I want to replace. I want to find the string of 3001 to replace it with a empty string, then find the string 3002 to replace it with 3001, find the string 3003 to replace it with 3004, find the string 3003 to replace it with 3004, find the string 3005 to replace it with 3004 and so on until I insert the 3010 data in a new cell just after the id "3009".
Just like this:
http://i.imgur.com/ZUK6ATG.jpg
I have not write a code for the update in a database, so I have got no idea how to search for the strings that I want to find them in a database before I could replace them with the strings that I want to replace.
Do you know how I could find the string in a database using the variable program_id to replace them with each of the strings that start from 3002 to 3010 to replace it with 3001 to 3009 and insert 3010 after the 3009 data??
Any advice will be greatly appreciated.
Thanks in advance