Reason why you're getting that error is because your salt
field is not allowing NULL values but you're trying to insert them, probably your table creation sql code looks something like this:
CREATE TABLE `access` (
`username` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
...
`salt` VARCHAR(50) NOT NULL COLLATE 'utf8_unicode_ci'
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB
;
If you just wanted to allow NULL values for that field maybe your SQL code would need to be change into something like:
...
`salt` VARCHAR(50) NULL COLLATE 'utf8_unicode_ci'
...
Anyway, if you still insist to keep your original db structure and want to learn how filter out warnings, here's a possible way to you could do it:
import pymysql
import warnings
db = pymysql.connect("localhost", "root", "", "raspi")
with warnings.catch_warnings():
warnings.simplefilter("ignore")
cursor = db.cursor()
cursor.execute("INSERT INTO access(username)VALUES('hello')")
db.commit()
db.close()
For more information, take a look to the warnings docs