How to store .wav file(media file) in sqllite databse



  • hey i have lots of .wav file(media) file and i want to store these file in sqllite database but i have no more idea about sqllite database .please help me how to store and retrive these data from sqllite.



  • I would suggest as a BLOB.

    To Retrieve It:
    @QByteArray ba1 = query.value(fieldNum).toByteArray();@

    To Set It:
    @QByteArray ba;
    QDataStream ds(&ba,QIODevice::WriteOnly);
    ds << wavFileContents;
    ...
    bstatus = query.prepare("INSERT INTO musicTable (id,name,media) " "VALUES (NULL, :name, :media)");
    query.bindValue(":name",fileName);
    query.bindValue(":media",ba);
    bstatus = query.exec();
    @



  • Thanks a lot DBoosalis ....please tell me what will be in the place of wavFileContents and how to use bstatus....actually i have no more idea about sqlite ....so please tell me step by step if its possible for u ...thanks in advance.



  • Hey Dboosalis tahnks, my problem has been solved .I can store bytearray in database and i can alsor retrive the bytearray(ba1) but i do not know how to get original file from these byte array . i can get image from these code
    @
    QSqlQuery query("SELECT Description,Signal FROM wav");
    query.next();
    QByteArray array = query.value(1).toByteArray();
    qDebug()<<array.length();

    QPixmap pixmap = QPixmap();
    pixmap.loadFromData(array);
    
    QPushButton *button = new QPushButton ();
    QIcon ButtonIcon(pixmap);
    
    button->setIcon(ButtonIcon);
    button->setIconSize(pixmap.rect().size());
    button->show();
    

    @

    but in case of .wav file how i will get original .wav file .

    [edit : please add @ tags around your code, Eddy]



  • I am no expert on wav files. Perhaps you should first try to write the QByteArray to a file with QFile::write(QByteArray) and then play it as you would normally.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.