Results 1 to 7 of 7
Maybe I got this totally wrong but I believe you can put MP3, video etc in a blob column.
How do I insert it? I believe mp3.com uses mysql to ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-05-2003 #1
inserting into BLOB column type
Maybe I got this totally wrong but I believe you can put MP3, video etc in a blob column.
How do I insert it? I believe mp3.com uses mysql to store there mp3 files.
Can anyone help me?I am on a journey to mastering Linux and I got a bloody long way to go!!!
- 08-05-2003 #2Linux Engineer
- Join Date
- Jan 2003
- Location
- Lebanon, pa
- Posts
- 994
Same way you would text data:
INSERT into <table> (blob_col) values ('data here');
With something like perl you could just do this:
open(FILE, "/path/to/file");
$blob=<FILE>;
$query='insert into blob_table (blob) values (?);';
$sth=$db -> prepare($query);
$sth -> execute($blob);
- 08-05-2003 #3
Thanks Genlee
Is there a way I can specify a path into the Insert command?
Something like Insert into mytable mp3column values(\path\to\mp3\)?
Let's say that I have all my files on the same box but in a different directory. What is the best way of doing this without using scriptI am on a journey to mastering Linux and I got a bloody long way to go!!!
- 08-06-2003 #4Linux Engineer
- Join Date
- Jan 2003
- Location
- Lebanon, pa
- Posts
- 994
INSERT INTO blob_tabl (some_col) values(load_file('/path/to/file')); ;
- 08-06-2003 #5Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
In that case, the easiest way to automate it is probably to run this command:
Code:(for file in /path/to/files/*; do echo 'INSERT INTO blob_tabl (some_col) values (load_file('\'"$file"\''));'; done) | mysql -D some_db -u some_user -p
- 08-06-2003 #6
Thanks guys, I will give that a go. Is there a special way to extract it as well? Lets say that I want to extract it to an other folder. Can I do this with a select statement?
CheersI am on a journey to mastering Linux and I got a bloody long way to go!!!
- 08-06-2003 #7Linux Engineer
- Join Date
- Apr 2003
- Location
- Sweden
- Posts
- 796
Use my program DBloader (engine) on my page (the link below) to load info of music or ftproot structures (or any other structure) in to mysql,mssql,postregsql..
you can easily modify it to load the mp3-file like a blob instead, if you need any help with that just let me know. Or if you have questions about the program.Regards
Andutt


Reply With Quote
