Skip navigation links

MySQL Forums :: Connector/Python :: Indexing with MySql


Advanced Search

Re: Indexing with MySql
Posted by: Geert Vanderkelen ()
Date: April 19, 2011 05:47AM

1) Why not use "CREATE TABLE IF NOT EXITS .." ? I also don't see the need of two tables. Just make one, and put PRIMARY KEY (mac). This means MACs will be unique.

2) You can try to insert the data and catch the exception when a duplicate key is found:
try:
cur.execute("INSERT INTO data (mac,..) VALUES ('newmacaddress',..)
except IntegrityError:
# Do something when the MAC was already in the table
else:
# Do something when the MAC was newly inserted

Sorry for the late reply, but I hope it helps anyways.

Geert

Geert Vanderkelen
Software Developer at Oracle

Options: ReplyQuote


Subject Written By Posted
Indexing with MySql John Smith 04/04/2011 03:55PM
Re: Indexing with MySql Geert Vanderkelen 04/19/2011 05:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.