Home > other >  For help, use the flask made up a mobile phone number registered backend, why enter a different phon
For help, use the flask made up a mobile phone number registered backend, why enter a different phon

Time:10-13

With flask made up a mobile phone number registered backend, why enter a different phone number, always appear in the mysql 2147483647, I have put it into the STR type

Heard that mysql can record the top number is 2147483647, so I put it into the STR type, but to no avail


class code is as follows: phonenum I defined as STR

Class User (the Model) :
__tablename__="user"
Id=db. The Column (db. The Integer, primary_key=True, nullable=False, autoincrement=True)
Username=db. The Column (the String (50), nullable=False, unique=True)
Phonenum=db. The Column (the String, nullable=False)
Password=db. The Column (the String (100), the nullable=False)



Registration code is as follows: phonenum I also put it into the STR


@ app. The route ('/regist/', the methods=[' GET 'and' POST '])
Def regist () :
. If the request method=='GET' :
Return render_template (' regist. HTML)

The else:
The username=request. Form. The get (" username ")
Phonenum=STR (request form. The get (" phonenum "))
Password1=request. Form. The get (" password1 ")
Password2.=the request form. The get (" password2 ")
# test whether mobile phone is registered, the query. The filter is the meaning of the query, was studied in the SQL, forget
# query. The mean filter to find the User class, phonenum did this project==phonenum
User=user. Query. The filter (user. Phonenum==phonenum). The first ()

If the user:
Return "the mobile phone number registered"

The else:

If password1!=password2:
Return 'two input password is not correct'

The else:
# added to the database
User=user (phonenum=phonenum, username=username and password=password1)
The db. The session. The add (user)
MIT ()
db.session.com# to jump to the login page
Return redirect (url_for (" login "))



However with watched recorded data in mysql navicat, is still 2147483647

As shown in figure

CodePudding user response:

When creating a table to declare character type char (11)

CodePudding user response:

reference 1st floor JMZL response:
create table statement when you need to character type char (11)

So, thank you very much!

CodePudding user response:

reference 1st floor JMZL response:
create table statement when you need to character type char (11)

So, thank you very much ah ha ha ha ha ha ha ha ha ha ha ha ha ha

CodePudding user response:

reference 1st floor JMZL response:
create table statement when you need to character type char (11)

So, thank you very much ah ha ha ha ha ha ha ha ha ha ha ha ha ha
  • Related