import sys
import hashlib
import getpass
from passlib.hash import sha256_crypt
import MySQLdb, random, os
def SQLAddPass(username, password):
SQL = 'insert into user values ("%s", "%s")' % (username, password)
try:
db = MySQLdb.connect (host='localhost', user='root', db='vedio')
c = db.cursor()
c.execute(SQL)
db.commit()
c.close()
db.close()
raw_input('Record Added - press enter to continue: ')
except:
print 'There was a problem adding the record'
raw_input ('press enter to continue')
def main(argv):
print '\nUser & Password Storage Program v.01\n'
username = raw_input('Please Enter a User Name: ')
password = sha256_crypt.encrypt(getpass.getpass('Please Enter a Password: '))
try:
SQLAddPass(username, password)
except:
sys.exit('There was a problem saving Record!')
print '\nPassword safely stored in ' + sys.argv[1] + '\n'
if __name__ == "__main__":
main(sys.argv[1:])
我的问题是脚本有效,但出现以下错误**
(C:\Users\Elsie\Desktop\example.py:14:警告:第 1 行 c.execute(SQL) 记录已截断列“密码”的数据 - 按 Enter 键继续:
**
密码安全地存储在数据库中。我做错了什么欢迎对代码的任何想法或更改)