Permalink
Browse files

On integrity error, update. Add indexes to pairs and tags table schemas

  • Loading branch information...
1 parent f3e194b commit 99050360813c657e8e3432f0ec377bfbf65d1989 @harryf committed Jan 26, 2009
Showing with 4 additions and 1 deletion.
  1. +4 −1 dammit/db_mysql.py
View
5 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)

0 comments on commit 9905036

Please sign in to comment.