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
Servers for Qt installer are currently down

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.
  • C Offline
    C Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on 19 Dec 2018, 17:37 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 20 Dec 2018, 02:38
    2
    • G greencow
      19 Dec 2018, 17:29

      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.

      J Offline
      J Offline
      JonB
      wrote on 19 Dec 2018, 20:42 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 20 Dec 2018, 02:50
      1
      • C Christian Ehrlicher
        19 Dec 2018, 17:37

        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 20 Dec 2018, 02:38 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.

        J J 2 Replies Last reply 20 Dec 2018, 05:30
        0
        • J JonB
          19 Dec 2018, 20:42

          @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 20 Dec 2018, 02:50 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
            20 Dec 2018, 02:38

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

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 20 Dec 2018, 05:30 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
              20 Dec 2018, 02:38

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

              J Offline
              J Offline
              JonB
              wrote on 20 Dec 2018, 09:44 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.

              J 1 Reply Last reply 20 Dec 2018, 09:47
              0
              • J JonB
                20 Dec 2018, 09:44

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

                J Offline
                J Offline
                jsulm
                Lifetime Qt Champion
                wrote on 20 Dec 2018, 09:47 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

                J 1 Reply Last reply 20 Dec 2018, 10:39
                0
                • J jsulm
                  20 Dec 2018, 09:47

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

                  J Offline
                  J Offline
                  JonB
                  wrote on 20 Dec 2018, 10:39 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 :)

                  J 1 Reply Last reply 20 Dec 2018, 11:42
                  0
                  • J JonB
                    20 Dec 2018, 10:39

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

                    J Offline
                    J Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on 20 Dec 2018, 11:42 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

                    J 1 Reply Last reply 20 Dec 2018, 12:11
                    0
                    • J jsulm
                      20 Dec 2018, 11:42

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

                      J Offline
                      J Offline
                      JonB
                      wrote on 20 Dec 2018, 12:11 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.

                      J 1 Reply Last reply 20 Dec 2018, 12:12
                      0
                      • J JonB
                        20 Dec 2018, 12: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.

                        J Offline
                        J Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on 20 Dec 2018, 12:12 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

                        J 1 Reply Last reply 20 Dec 2018, 12:14
                        0
                        • J jsulm
                          20 Dec 2018, 12:12

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

                          J Offline
                          J Offline
                          JonB
                          wrote on 20 Dec 2018, 12:14 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".

                          J 1 Reply Last reply 20 Dec 2018, 12:18
                          0
                          • J JonB
                            20 Dec 2018, 12:14

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

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 20 Dec 2018, 12:18 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

                            J 1 Reply Last reply 20 Dec 2018, 12:20
                            0
                            • J jsulm
                              20 Dec 2018, 12:18

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

                              J Offline
                              J Offline
                              JonB
                              wrote on 20 Dec 2018, 12:20 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. :)

                              J 1 Reply Last reply 20 Dec 2018, 12:21
                              0
                              • J JonB
                                20 Dec 2018, 12:20

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

                                J Offline
                                J Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 20 Dec 2018, 12:21 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

                                11/16

                                20 Dec 2018, 12:11

                                • Login

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