Skip to content

Commit

Permalink
Add support for deleting table (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
taoyl-ms authored Feb 15, 2018
1 parent 93010e1 commit f0980a0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/swsssdk/configdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,18 @@ def get_table(self, table):
pass #Ignore non table-formated redis entries
return data

def delete_table(self, table):
"""Delete an entire table from config db.
Args:
table: Table name.
"""
client = self.redis_clients[self.CONFIG_DB]
pattern = '{}{}*'.format(table.upper(), self.TABLE_NAME_SEPARATOR)
keys = client.keys(pattern)
data = {}
for key in keys:
client.delete(key)

def mod_config(self, data):
"""Write multiple tables into config db.
Extra entries/fields in the db which are not in the data are kept.
Expand Down

0 comments on commit f0980a0

Please sign in to comment.