mysql IntegrityError: (pymysql.err.IntegrityError) (1062, "Duplicate entry '000001.SZ-2018-07-02' for key 'PRIMARY'")

IntegrityError: (pymysql.err.IntegrityError) (1062, "Duplicate entry '000001.SZ-2018-07-02' for key 'PRIMARY'")
[SQL: INSERT INTO stock_daily_basic (ts_code, trade_date, close, turnover_rate, turnover_rate_f, volume_ratio, pe, pe_ttm, pb, ps, ps_ttm, dv_ratio, dv_ttm, total_share, float_share, free_share, total_mv, circ_mv) VALUES (%(ts_code)s, %(trade_date)s, %(close)s, %(turnover_rate)s, %(turnover_rate_f)s, %(volume_ratio)s, %(pe)s, %(pe_ttm)s, %(pb)s, %(ps)s, %(ps_ttm)s, %(dv_ratio)s, %(dv_ttm)s, %(total_share)s, %(float_share)s, %(free_share)s, %(total_mv)s, %(circ_mv)s)]
[parameters: ({'ts_code': '600230.SH', 'trade_date': '20180702', 'close': 22.84, 'turnover_rate': 3.2284, 'turnover_rate_f': 6.0057, 'volume_ratio': 1.99, 'pe': 7.3318, 'pe_ttm': 7.49, 'pb': 3.1378, 'ps': 2.1296, 'ps_ttm': 2.0831, 'dv_ratio': 0.41, 'dv_ttm': 1.56, 'total_share': 41186.3502, 'float_share': 41186.3502, 'free_share': 22139.6078, 'total_mv': 940696.2386, 'circ_mv': 940696.2386},

 

Data is provided in Table primary key (Primary Key), and a value corresponding to the primary key is not allowed to repeat.
Error message is: the primary key of your records and insert data in the table repeat the original records (Duplicate). So insert fails.

NOTE: the fields added checklist "unique = True" attribute, when adding a record is added duplicate values.

 

Sqlalchemy error message given by:

https://docs.sqlalchemy.org/en/13/errors.html#error-gkpj

IntegrityError

Exception raised when the relational integrity of the database is affected, e.g. a foreign key check fails.

This error is a DBAPI Error and originates from the database driver (DBAPI), not SQLAlchemy itself.

 

Guess you like

Origin www.cnblogs.com/ttrrpp/p/12610654.html