Skip to content

Commit

Permalink
On integrity error, update. Add indexes to pairs and tags table schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
harryf committed Jan 26, 2009
1 parent f3e194b commit 9905036
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dammit/db_mysql.py
Expand Up @@ -139,7 +139,8 @@ def insert(self, uri):
try: try:
cursor.execute( sql, params ) cursor.execute( sql, params )
except IntegrityError: except IntegrityError:
# Duplicate key - we don't care # update instead...
self.update(uri)
return return


self._store_tags(cursor, uri, deletefirst = False) self._store_tags(cursor, uri, deletefirst = False)
Expand Down Expand Up @@ -229,6 +230,7 @@ def bootstrap(self, dropfirst = False):
sql = """CREATE TABLE IF NOT EXISTS urldammit_tags ( sql = """CREATE TABLE IF NOT EXISTS urldammit_tags (
id BINARY( 40 ) NOT NULL , id BINARY( 40 ) NOT NULL ,
tag VARCHAR( %s ) NOT NULL tag VARCHAR( %s ) NOT NULL
KEY id_index (id)
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci; ) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;
""" % ( constants.URI_TAG_LEN ) """ % ( constants.URI_TAG_LEN )
cursor.execute(sql) cursor.execute(sql)
Expand All @@ -237,6 +239,7 @@ def bootstrap(self, dropfirst = False):
id BINARY( 40 ) NOT NULL , id BINARY( 40 ) NOT NULL ,
pair_key VARCHAR( %s ) NOT NULL , pair_key VARCHAR( %s ) NOT NULL ,
pair_value VARCHAR( %s ) NOT NULL pair_value VARCHAR( %s ) NOT NULL
KEY id_index (id)
) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci; ) ENGINE = innodb CHARACTER SET utf8 COLLATE utf8_unicode_ci;
""" % ( constants.URI_PAIR_KEY_LEN, constants.URI_PAIR_VALUE_LEN ) """ % ( constants.URI_PAIR_KEY_LEN, constants.URI_PAIR_VALUE_LEN )
cursor.execute(sql) cursor.execute(sql)
Expand Down

0 comments on commit 9905036

Please sign in to comment.