Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

Duplicate PRIMARY key problem (no replies)

$
0
0
environment:
mysql 5.7 on rhl6
mysql-python/connector
python 2.7.12 on windows, python 2.6.6 on rhl6

I have a time-series fact table with primary key on ID and a timestamp column. The ID column is a mysql auto-gen column and is unique for every new record inserted into this table. (why the timestamp column is in the primary key is not import here).

I'm writing a python script to popuate the table with records for a list of objects at every 15-minute mark.

The table was initially empty. I started populating the table from 00-minute mark, and records were committed to the table without problem. But it failed on the first 15-minute mark record with a duplicate PRIMARY key error.

I truncated the table and started the script again, it failed at the same place with the same error.

I truncated the table and change the script to start from 15-minute mark, the script successfully created and committed all the 15-minute mark records, then failed at the first 30-minute mark record with the same duplicate PRIMARY key error.

I then get the "create table" statement from workbench, drop and recreate the table, rerun the script, everything works fine. The problem disappeared!

Now I'm scratching my head to try to understand this. Could somebody help me please?

Viewing all articles
Browse latest Browse all 384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>