Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Send and retrieve video to database sql from disk

Send and retrieve video to database sql from disk

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 4 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    greencow
    wrote on last edited by
    #1

    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.

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Why do you want to store a video/a big chunk of data in a database? This is not what databases are made for...

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      G 1 Reply Last reply
      2
      • G greencow

        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.

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @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 literal INSERT ... VALUES (...) statement, I wonder whether that would cause a problem... [EDIT: Hmm, maybe it's OK, mysqldump must do something for it...]

        G 1 Reply Last reply
        1
        • Christian EhrlicherC Christian Ehrlicher

          Why do you want to store a video/a big chunk of data in a database? This is not what databases are made for...

          G Offline
          G Offline
          greencow
          wrote on last edited by
          #4

          @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.

          jsulmJ JonBJ 2 Replies Last reply
          0
          • JonBJ JonB

            @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 literal INSERT ... VALUES (...) statement, I wonder whether that would cause a problem... [EDIT: Hmm, maybe it's OK, mysqldump must do something for it...]

            G Offline
            G Offline
            greencow
            wrote on last edited by
            #5

            @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!

            1 Reply Last reply
            0
            • G greencow

              @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.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @greencow You can store the video in the file system and the path to the video file in the database.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • G greencow

                @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.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #7

                @greencow
                As @jsulm suggests.

                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.

                jsulmJ 1 Reply Last reply
                0
                • JonBJ JonB

                  @greencow
                  As @jsulm suggests.

                  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.

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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).

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  JonBJ 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @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).

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @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 :)

                    jsulmJ 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @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 :)

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @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.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      JonBJ 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @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.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on last edited by JonB
                        #11

                        @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.

                        jsulmJ 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @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.

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          @JonB Well, yes with raw SQL you can't. But if you're accessing some APIs (like REST) server can do this.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          JonBJ 1 Reply Last reply
                          0
                          • jsulmJ jsulm

                            @JonB Well, yes with raw SQL you can't. But if you're accessing some APIs (like REST) server can do this.

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #13

                            @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".

                            jsulmJ 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @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".

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              @JonB In this case he needs to store the video as binary blob in the db...

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              JonBJ 1 Reply Last reply
                              0
                              • jsulmJ jsulm

                                @JonB In this case he needs to store the video as binary blob in the db...

                                JonBJ Offline
                                JonBJ Offline
                                JonB
                                wrote on last edited by
                                #15

                                @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. :)

                                jsulmJ 1 Reply Last reply
                                0
                                • JonBJ JonB

                                  @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. :)

                                  jsulmJ Offline
                                  jsulmJ Offline
                                  jsulm
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  @JonB And here we are again at the point to suggest to not to store it in the db :-)

                                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved