worldveil / dejavu

Audio fingerprinting and recognition in Python
MIT License
6.36k stars 1.43k forks source link

MySQLdb._exceptions.IntegrityError: (1364, "Field 'file_sha1' doesn't have a default value") #240

Closed mayank128 closed 3 years ago

mayank128 commented 3 years ago

Able to make fingerprint of audio mp3 files, but when it comes to save those into database it throw this error.

Finished channel 2/2 for /home/mayank/Music/dejavu-master/mp3/Brad-Sucks--Total-Breakdown.mp3 Traceback (most recent call last): File "newtest.py", line 11, in djv.fingerprint_directory("/home/mayank/Music/dejavu-master/mp3", [".mp3"]) File "/home/mayank/dejavu/newclone/dejavu_audio_fingerprint/dejavu/init.py", line 86, in fingerprint_directory sid = self.db.insert_song(songname) File "/home/mayank/dejavu/newclone/dejavuaudio_fingerprint/dejavu/database_sql.py", line 243, in insert_song cur.execute(self.INSERT_SONG, (songname,)) File "/home/mayank/dejavu/newclone/P27/lib/python2.7/site-packages/MySQLdb/cursors.py", line 209, in execute res = self._query(query) File "/home/mayank/dejavu/newclone/P27/lib/python2.7/site-packages/MySQLdb/cursors.py", line 315, in _query db.query(q) File "/home/mayank/dejavu/newclone/P27/lib/python2.7/site-packages/MySQLdb/connections.py", line 239, in query _mysql.connection.query(self, query) MySQLdb._exceptions.IntegrityError: (1364, "Field 'file_sha1' doesn't have a default value")

abhishek09091 commented 3 years ago

Error is happening due not availablity of the default value for the file_sha1 in ur table. Make file_sha1 column as to accept NULL or while inserting into the table pass the value for file_sha1

I am not sure about the syntax but probably this will remove the error.

Hope so this help and clear your doubt.

mayank128 commented 3 years ago

Error is happening due not availablity of the primary key in ur table. Add a primary key column in your table.

I am not sure about the syntax but u need to tell your library that this field is going to be primary key in ur table.

Hope so this help and clear your doubt.

It worked..Thank you so much for the help :+1: