MySQL Forums
Forum List  »  Connector/Python

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:
cur.execute("INSERT INTO data (mac,..) VALUES ('newmacaddress',..)
except IntegrityError:
# Do something when the MAC was already in the table
# Do something when the MAC was newly inserted

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


Geert Vanderkelen
Software Developer at Oracle

Options: ReplyQuote

Written By
April 04, 2011 03:55PM
Re: Indexing with MySql
April 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.