Re: Blob retrieval from database using shell

2005-07-31 Thread Enrique Sanchez Vela

to compare binary files "cmp" does a better work than
diff. to answer your question ...echo might be adding
a new-line char (\n) at the end of the file, why don't
you try printf, most shells include such, also try the
echo switches not to print the new-line at the end of
the command (for bash: echo -n "hi")



regards,
esv


--- Rakesh Gupta <[EMAIL PROTECTED]> wrote:

> 
> 
> 
> 
> Hi There,
> I am trying to insert blob in table and then
> retrieve it from table using
> Linux shell. Here is script that i used.
> 
> Load Blob into DB and Retrieve it using linux shell.
> # add firmware into DB
> ACTION="insert into FIRMWARE
> (firmwarename, releasedate, bootcodename,
> usermanualname, releasenotes,
> checksum, hwrevision, comments, dependencyfwid)
> values (\"$FWNAME\", \"$RELDATE\", \"$BOOTNAME\",
> \"$MANUAL\",
> LOAD_FILE(\"$FW/$1/$BRNOTES\"), \"$CHECK\",
> \"$HWREV\", \"$COMMENT\",
> $FWDEPID);
> VALUE=`echo "$ACTION" | mysql -u$APMU -p$APMPW
> -h$HOSTDB -D$APMDB`
> if [ $? != 0 ]; then
> echo $ACTION >> $LOG
> echo $VALUE >> $LOG
> echo [DBERR-002] >> $LOG
> continue
> fi
> 
> select length(firmwareimage) from FIRMWARE where
> firmwareid=129;
> 
> 
> +---+
> | length(firmwareimage) |
> +---+
> |   3763016 |
> +---+
> 
> It shows the correct size of binary file
> 
> # get  blob from Database
> 
> ACTION="select firmwareimage from FIRMWARE where
> status !='Deleted' and
> firmwareid=$1 ;"
> VALUE=`echo "$ACTION" | mysql -u$APMU -p$APMPW
> -h$HOSTDB -D$APMDB`
> if [ $? != 0 ]; then
> echo $ACTION >> $LOG
> echo [DBERR-001] >> $LOG
> continue
> fi
> echo $VALUE > /tmp/tmp_129.bin
> 
> [EMAIL PROTECTED] tmp]# diff ts_129.bin tmp_129.bin
> Binary files ts_129.bin and tmp_129.bin differ
> 
> Retrieved binary file size increases. Does anyone
> know about this issue and
> how to fix it.
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:   
>
http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 


Enrique Sanchez Vela
email: [EMAIL PROTECTED]
-
It's often easier to fight for one's||We live in the outer space
   
principles than to live up to them||Rev. Kay Greenleaf
Adlai Stevenson||

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: Blob retrieval from database using shell

2005-07-30 Thread Gleb Paharenko
Hello.



Maybe mysql puts the name of the column (firmwareimage),

at the beginning of the output (--skip-column-names should prevent it).







Rakesh Gupta <[EMAIL PROTECTED]> wrote:

> 

> 

> 

> 

> Hi There,

> I am trying to insert blob in table and then retrieve it from table using

> Linux shell. Here is script that i used.

> 

> Load Blob into DB and Retrieve it using linux shell.

> # add firmware into DB

> ACTION="insert into FIRMWARE

> (firmwarename, releasedate, bootcodename, usermanualname, releasenotes,

> checksum, hwrevision, comments, dependencyfwid)

> values (\"$FWNAME\", \"$RELDATE\", \"$BOOTNAME\", \"$MANUAL\",

> LOAD_FILE(\"$FW/$1/$BRNOTES\"), \"$CHECK\", \"$HWREV\", \"$COMMENT\",

> $FWDEPID);

> VALUE=`echo "$ACTION" | mysql -u$APMU -p$APMPW -h$HOSTDB -D$APMDB`

> if [ $? != 0 ]; then

> echo $ACTION >> $LOG

> echo $VALUE >> $LOG

> echo [DBERR-002] >> $LOG

> continue

> fi

> 

> select length(firmwareimage) from FIRMWARE where firmwareid=129;

> 

> 

> +---+

> | length(firmwareimage) |

> +---+

> |   3763016 |

> +---+

> 

> It shows the correct size of binary file

> 

> # get  blob from Database

> 

> ACTION="select firmwareimage from FIRMWARE where status !='Deleted' and

> firmwareid=$1 ;"

> VALUE=`echo "$ACTION" | mysql -u$APMU -p$APMPW -h$HOSTDB -D$APMDB`

> if [ $? != 0 ]; then

> echo $ACTION >> $LOG

> echo [DBERR-001] >> $LOG

> continue

> fi

> echo $VALUE > /tmp/tmp_129.bin

> 

> [EMAIL PROTECTED] tmp]# diff ts_129.bin tmp_129.bin

> Binary files ts_129.bin and tmp_129.bin differ

> 

> Retrieved binary file size increases. Does anyone know about this issue and

> how to fix it.

> 

> 



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
   <___/   www.mysql.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]