I have a database named “crea” with a table named “assets” and in this table i have 11 column named (name,description,assetType,local,temporary,data,id,create_time,access_time,asset_flags,CreatorID)
I also have a directory folder with many picture in .jp2 format (xxxx.jp2)
What im trying to do is to bulk insert these picture in the table “assets” of my database, so i decided to do it with 2 shell scripts, the both are in the directory with the pictures.
When i launch ./assetadd.sh from the terminal, i get this error from MySQL :
ERROR 1048 (23000) at line 1: Column 'data' cannot be null
I checked many time and im sure that the column ‘data’ isnt NULL (Type: LONGBLOB Binaries Null: NO), so i really dont understand why i get this error.
Help will be apreciated. Thank you
– Script 1 : assetsadd.sh
#!/bin/bash
path=$(pwd)
find $path/ -type f \( -iname *.jp2 \) -exec ./insertjp2.sh {} \;
echo "finished!!"
– Script 2 : insertjp2.sh
#!/bin/bash
user="crea"
password="crea"
database="crea"
dbhost="localhost"
creator="crea"
param=$@
basenam=${param##*/}
filenam=${basenam%.*}
MYSQL=`/usr/bin/mysql -u$user -p$password -D$database -e"INSERT INTO assets (name,description,assetType,local,temporary,data,id,create_time,access_time,asset_flags,CreatorID) VALUES ('$filenam','$filenam',0,0,0,LOAD_FILE('$param'),'$filenam',UNIX_TIMESTAMP(),1325304546,0,'$creator' );"`
echo $param >> assetadd.log
echo $MYSQL
From the documentation for LOAD_FILE:
It looks like at the very least, you are not specifying the full path to the file name.