N
N
Nikita Shchypylov2017-09-22 16:41:20
MySQL
Nikita Shchypylov, 2017-09-22 16:41:20

Why does it give an error: 1062, u"Duplicate entry 'pbkdf2:sha256:50000$' for key 'user_password'"?

Hello everyone
Code for adding a user:

# read the posted value
    _name = request.form['inputName']
    _email = request.form['inputEmail']
    _password = request.form['inputPassword']

    # validate values
    if _name and _email and _password:
        # let's go
        conn = mysql.connect()
        cursor = conn.cursor()
        _hashed_password = generate_password_hash(_password)
        cursor.callproc('sp_createUser', (_name, _email, _hashed_password))
        data = cursor.fetchall()

        if (len(data) is 0): 
            conn.commit()
            return json.dumps({'message': 'User created successfully !'})
        else:
            return json.dumps({'error': str(data[0])})


If with this code I enter data, I get this error:
DataError: (1406, u"Data too long for column 'p_password' at row 1")

This error is treated by this command:
mysql> SET @@global.sql_mode= '';
Now this error occurs when entering data:
IntegrityError: ( 1062, u"Duplicate entry 'pbkdf2:sha256:50000$' for key 'user_password'")

What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-09-22
@Sanasol

"Duplicate entry 'pbkdf2:sha256:50000$' for key 'user_password'")

unique key on the password field? It's brilliant :D

T
ThunderCat, 2017-09-22
@ThunderCat

The first app, and then according to the guide

The value of learning from the guide (and, accordingly, the quality of the guide) is that in the guide they give an idea of ​​what and why we are doing, if something written remains a “black box” for you, such as “we write this line and everything works”, then the guide is not worth it download traffic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question