(self, list_)
| 970 | |
| 971 | # this method updates category_db_table |
| 972 | def updateCategoryTable(self, list_): |
| 973 | # lock data base |
| 974 | self.lockCursor() |
| 975 | |
| 976 | keys_list = ['category', |
| 977 | 'start_time_enable', |
| 978 | 'start_time', |
| 979 | 'end_time_enable', |
| 980 | 'end_time', |
| 981 | 'reverse', |
| 982 | 'limit_enable', |
| 983 | 'limit_value', |
| 984 | 'after_download', |
| 985 | 'gid_list'] |
| 986 | |
| 987 | for dict_ in list_: |
| 988 | |
| 989 | # format of gid_list is list and must be converted to string for sqlite3 |
| 990 | if 'gid_list' in dict_.keys(): |
| 991 | dict_['gid_list'] = str(dict_['gid_list']) |
| 992 | |
| 993 | for key in keys_list: |
| 994 | # if a key is missed in dict_, |
| 995 | # then add this key to the dict_ and assign None value for the key. |
| 996 | if key not in dict_.keys(): |
| 997 | dict_[key] = None |
| 998 | |
| 999 | # update data base if value for the keys is not None |
| 1000 | self.persepolis_db_cursor.execute("""UPDATE category_db_table SET start_time_enable = coalesce(:start_time_enable, start_time_enable), |
| 1001 | start_time = coalesce(:start_time, start_time), |
| 1002 | end_time_enable = coalesce(:end_time_enable, end_time_enable), |
| 1003 | end_time = coalesce(:end_time, end_time), |
| 1004 | reverse = coalesce(:reverse, reverse), |
| 1005 | limit_enable = coalesce(:limit_enable, limit_enable), |
| 1006 | limit_value = coalesce(:limit_value, limit_value), |
| 1007 | after_download = coalesce(:after_download, after_download), |
| 1008 | gid_list = coalesce(:gid_list, gid_list) |
| 1009 | WHERE category = :category""", dict_) |
| 1010 | |
| 1011 | # commit changes |
| 1012 | self.persepolis_db_connection.commit() |
| 1013 | |
| 1014 | # job is done! open the lock |
| 1015 | self.lock = False |
| 1016 | |
| 1017 | # this method updates addlink_db_table |
| 1018 | def updateAddLinkTable(self, list_): |
no test coverage detected