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:])
My problem is that the script works but with the following error **
(C:\Users\Elsie\Desktop\example.py:14: Warning: Data truncated for column 'passwo rd' at row 1 c.execute(SQL) Record Added - press enter to continue:
**
Password safely stored in database. What am i doing wrong any ideas or changes to the code are welcome)