Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Inserting and pulling images from sql [solved]
Forum Updated to NodeBB v4.3 + New Features

Inserting and pulling images from sql [solved]

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.5k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    dstudentx
    wrote on 19 Jun 2013, 20:46 last edited by
    #1

    Is there a way to insert and pull images from a sql db? I can do it with text but can't figure out how to do it with images.

    here is what I'm doing for inserting and grabbing txt is there a way to change this up so I can use it for images?

    @
    var index_count = 0
    var up_check = 0
    var r = "rr"

    function get_db(a, up_check) {
    var db = LocalStorage.openDatabaseSync("DB5", "1.0", "The Example QML SQL!",
    1000000);
    db.transaction(
    function(tx) {
    tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT,
    salutee TEXT)');
    for ( var z=0; z<1000; z++){
    tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'Movie', z ]);
    }
    var rs = tx.executeSql('SELECT * FROM Greeting');
    r=""
    if (index_count <0)
    index_count=0;
    // for(var i = 0; i < sa; i++) {
    if (up_check === 0)
    r += rs.rows.item(index_count).salutation + ": " +
    rs.rows.item(index_count).salutee + "\t\t"
    if (up_check === 1){
    r += rs.rows.item(index_count).salutation + ": " +
    rs.rows.item(index_count).salutee + "\t\t"
    }
    }
    //}
    )
    console.log(r);
    index_count=a;
    return r;
    }
    @

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dstudentx
      wrote on 19 Jun 2013, 23:05 last edited by
      #2

      Maybe I should restate this question.
      How can I have a folder of say 1000 images loaded in a db to be used like and array or var

      1 Reply Last reply
      0
      • P Offline
        P Offline
        portoist
        wrote on 20 Jun 2013, 06:27 last edited by
        #3

        I am not sure if it is a good practice to store images into database. You should define your column as BLOB. You will need to write some C++ class to get binary data of image you want to save. and to display image from binary data retrieved from DB.
        As for me I would save images in file system and store their paths in database, I think that it is better and more simple solution.

        1 Reply Last reply
        0

        1/3

        19 Jun 2013, 20:46

        • Login

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