From 99050360813c657e8e3432f0ec377bfbf65d1989 Mon Sep 17 00:00:00 2001 From: Harry Fuecks Date: Mon, 26 Jan 2009 22:33:20 +0100 Subject: [PATCH] On integrity error, update. Add indexes to pairs and tags table schemas --- dammit/db_mysql.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dammit/db_mysql.py b/dammit/db_mysql.py index db3407a..5d1925c 100644 --- a/dammit/db_mysql.py +++ b/dammit/db_mysql.py @@ -139,7 +139,8 @@ def insert(self, uri): try: cursor.execute( sql, params ) except IntegrityError: - # Duplicate key - we don't care + # update instead... + self.update(uri) return self._store_tags(cursor, uri, deletefirst = False) @@ -229,6 +230,7 @@ def bootstrap(self, dropfirst = False): sql = """CREATE TABLE IF NOT EXISTS urldammit_tags ( id BINARY( 40 ) NOT NULL , tag VARCHAR( %s ) NOT NULL + KEY id_index (id) ) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci; """ % ( constants.URI_TAG_LEN ) cursor.execute(sql) @@ -237,6 +239,7 @@ def bootstrap(self, dropfirst = False): id BINARY( 40 ) NOT NULL , pair_key VARCHAR( %s ) NOT NULL , pair_value VARCHAR( %s ) NOT NULL + KEY id_index (id) ) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci; """ % ( constants.URI_PAIR_KEY_LEN, constants.URI_PAIR_VALUE_LEN ) cursor.execute(sql)