Quantcast

Inserting an image file?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Inserting an image file?

aditya siram-2
Hi all,
How do I insert an image file into sqlite table? Can I just use a
path-specifier? For instance,
create table ("name" varchar, "data" blob);
insert into table ("someBlob", "./blob.jpg");

thanks,
deech
_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting an image file?

Igor Tandetnik
"aditya siram" <[hidden email]>
wrote in message
news:[hidden email]
> How do I insert an image file into sqlite table? Can I just use a
> path-specifier? For instance,
> create table ("name" varchar, "data" blob);
> insert into table ("someBlob", "./blob.jpg");

No, SQLite won't read the file for you. You will have to read the data
into memory yourself, then insert it into the table (you could possibly
use memory-mapped files - see CreateFileMapping on Windows, mmap on
Linux). The easiest way is perhaps to use a parameterized query - see
sqlite3_bind_blob.

Alternatively, you could use incremental BLOB API
(http://sqlite.org/c3ref/blob_open.html). Useful for large files, as you
don't need to have all the data in memory at once.

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting an image file?

Teg-3
In reply to this post by aditya siram-2
Hello aditya,

Friday, January 2, 2009, 2:08:38 PM, you wrote:

as> Hi all,
as> How do I insert an image file into sqlite table? Can I just use a
as> path-specifier? For instance,
as> create table ("name" varchar, "data" blob);
as> insert into table ("someBlob", "./blob.jpg");

as> thanks,
as> deech
as> _______________________________________________
as> sqlite-users mailing list
as> [hidden email]
as> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

I do it with memory mapped files and a single write to the DB using
a paramaterized query.

--
Best regards,
 Teg                            mailto:[hidden email]

_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting an image file?

schachtobi
In reply to this post by aditya siram-2
Hello,

I have an open source application using that. You can look at the
complete source here:

http://getamosaic.svn.sourceforge.net/viewvc/getamosaic/trunk/GetAMosaic/dbAccess.c?revision=28&view=markup

Method name: dbAddCharacteristicWData

regards,
Tobias

aditya siram schrieb:
> How do I insert an image file into sqlite table? Can I just use a
> path-specifier? For instance,
> create table ("name" varchar, "data" blob);
> insert into table ("someBlob", "./blob.jpg");



_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Inserting an image file?

mikewhit
In reply to this post by aditya siram-2
aditya siram <aditya.siram@...> writes:

>
> Hi all,
> How do I insert an image file into sqlite table? Can I just use a
> path-specifier? For instance,
> create table ("name" varchar, "data" blob);
> insert into table ("someBlob", "./blob.jpg");
>
> thanks,
> deech

But obviously holding the image within the DB means your DB file gets bigger,
reducing the effectiveness of memory caching.

You could have INSERT and DELETE triggers (and maybe an extra table)
to manage the image files, and just store the image filenames in the DB.

But you knew that !

MikeW



_______________________________________________
sqlite-users mailing list
[hidden email]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
Loading...