Results 1 to 3 of 3

Thread: insert binary data into sqlite

  1. #1
    Join Date
    Sep 2010
    Location
    Bangalore
    Posts
    169
    Thanks
    59
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default insert binary data into sqlite

    Hi everyone,
    I am using qt 4.7.I am trying to store binary data.My binary data is present in QByteArray.
    Can any one tell me how to insert ? What is the create and insert statement ?

    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: insert binary data into sqlite

    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: insert binary data into sqlite

    I think you can use BLOB datatype for the data field, so create could look like:
    Qt Code:
    1. CREATE TABLE test( data BLOB NOT NULL );
    To copy to clipboard, switch view to plain text mode 
    and insert QByteArray as any other value, for example:
    Qt Code:
    1. QByteArray bytes;
    2. ...
    3. QSqlQuery query(db);
    4. query.prepare("INSERT INTO test(data) VALUES(:data);");
    5. query.bindValue(":data",bytes);
    6. query.exec();
    To copy to clipboard, switch view to plain text mode 
    Last edited by stampede; 24th March 2011 at 13:14. Reason: too slow again :)

Similar Threads

  1. Insert unicode in SQlite
    By Kastagne in forum Qt Programming
    Replies: 3
    Last Post: 11th October 2011, 14:07
  2. Replies: 13
    Last Post: 6th December 2010, 04:41
  3. How to insert row to SQLite database?
    By MIH1406 in forum Qt Programming
    Replies: 6
    Last Post: 29th May 2010, 12:22
  4. Replies: 0
    Last Post: 21st April 2010, 16:25
  5. Bulk insert into SQLite
    By munna in forum Qt Programming
    Replies: 6
    Last Post: 19th November 2007, 03:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.