Send and retrieve video to database sql from disk
-
As the title mentioned, I would like to send and retrieve video from disk to database sql. Is it possible to make it ? From what I understand first making the video to byte array after that convert into string then save into database. However, there's no much information could search online for send and retrieve video to database sql from disk and from database sql. Thank you in advance for replying.
-
Why do you want to store a video/a big chunk of data in a database? This is not what databases are made for...
-
As the title mentioned, I would like to send and retrieve video from disk to database sql. Is it possible to make it ? From what I understand first making the video to byte array after that convert into string then save into database. However, there's no much information could search online for send and retrieve video to database sql from disk and from database sql. Thank you in advance for replying.
@greencow
In addition to @Christian-Ehrlicher 's response that this is perhaps not a good idea. You can store arbitrary binary data in SQL databases. In principle the approach you mention will work. However, if your video is "large" doing it from Qt client is, I think, going to generate a huge literalINSERT ... VALUES (...)
statement, I wonder whether that would cause a problem... [EDIT: Hmm, maybe it's OK,mysqldump
must do something for it...] -
Why do you want to store a video/a big chunk of data in a database? This is not what databases are made for...
@Christian-Ehrlicher Thank you for replying! I was thinking to play video from the database like the database act as the server to send through to the client. I think my concept is wrong, thank you for pointing it out.
-
@greencow
In addition to @Christian-Ehrlicher 's response that this is perhaps not a good idea. You can store arbitrary binary data in SQL databases. In principle the approach you mention will work. However, if your video is "large" doing it from Qt client is, I think, going to generate a huge literalINSERT ... VALUES (...)
statement, I wonder whether that would cause a problem... [EDIT: Hmm, maybe it's OK,mysqldump
must do something for it...]@JonB Thank you for replying! The reason posting this question is to seek for alternative ways to do the same things. Anyway , I will still go with the approach I mentioned. Thank you so much for helping, will do some searching on mysqldump! Thanks a lot!
-
@Christian-Ehrlicher Thank you for replying! I was thinking to play video from the database like the database act as the server to send through to the client. I think my concept is wrong, thank you for pointing it out.
-
@Christian-Ehrlicher Thank you for replying! I was thinking to play video from the database like the database act as the server to send through to the client. I think my concept is wrong, thank you for pointing it out.
Storing a large video in a database is not good for what you want. The video player cannot play it from there, so the first thing which will have to be done every time is to extract the whole huge data from the database to store it into a local file for the video player to play from there. That's really slow! Keeping the video in a local file is going to be way more appropriate.
-
Storing a large video in a database is not good for what you want. The video player cannot play it from there, so the first thing which will have to be done every time is to extract the whole huge data from the database to store it into a local file for the video player to play from there. That's really slow! Keeping the video in a local file is going to be way more appropriate.
@JonB @greencow One improvement for my suggestion: store root path to the directory containing the video files once, then for each video only store relative path (relative to root path). This way you can easily move all videos to a different location if needed without the need to change all paths in the database (only the root path needs to be changed then).
-
@JonB @greencow One improvement for my suggestion: store root path to the directory containing the video files once, then for each video only store relative path (relative to root path). This way you can easily move all videos to a different location if needed without the need to change all paths in the database (only the root path needs to be changed then).
@jsulm , @greencow
In that case, personally I would not store the root path in the database! It has nothing to do with the database/data, and any operations which extract a data row from the db to file will have to be performed 100% client-side to a file. So what directory you choose to extract to is an arbitrary decision (e.g. could vary from machine to machine), I would decide that purely in client-side code :) -
@jsulm , @greencow
In that case, personally I would not store the root path in the database! It has nothing to do with the database/data, and any operations which extract a data row from the db to file will have to be performed 100% client-side to a file. So what directory you choose to extract to is an arbitrary decision (e.g. could vary from machine to machine), I would decide that purely in client-side code :)@JonB I think you misunderstood my point. If both, database and files, are stored on server side and you store the path to the file in the database then it makes sense (in my opinion) to only store relative path in the database. Where the client stores the file later is completely irrelevant for the server, but the server needs to know where the file is stored (on server side) to be able to provide it to the client.
-
@JonB I think you misunderstood my point. If both, database and files, are stored on server side and you store the path to the file in the database then it makes sense (in my opinion) to only store relative path in the database. Where the client stores the file later is completely irrelevant for the server, but the server needs to know where the file is stored (on server side) to be able to provide it to the client.
-
@jsulm
How can a SQL server, even armed with a full path to a file, serve/"provide" that file? SQL (as SQL) can't do that --- it's a file, not a row in a database. -
@JonB Well, yes with raw SQL you can't. But if you're accessing some APIs (like REST) server can do this.
-
@jsulm
OK, but the OP said "video from disk to database sql". Not "oh by the way I have some other RESTful server API available to me". -
@jsulm
Which is where we started from :) And as I said will be terribly inefficient, as the whole blob will need extracting and saving to file each time (by the client) in order to access the video. :)