How to insert the BLOB in database?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

How to insert the BLOB in database?

Igor Korot
Hi, ALL,
Let's say I have some database, where I have table called test.
This test table contains the field whose type is BLOB.

Now I open this database in sqlite3 CLI binary and would like to insert some png
file inside this BLOB field. And I am not talking about the file name
- the actual
content of the png.

Is there a way to do that from the CLI?

Thank you.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How to insert the BLOB in database?

Richard Hipp-3
On 6/9/19, Igor Korot <[hidden email]> wrote:
>
> Now I open this database in sqlite3 CLI binary and would like to insert some
> png
> file inside this BLOB field.


INSERT INTO tab1(blob1) VALUES(readfile('some.png'));

--
D. Richard Hipp
[hidden email]
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How to insert the BLOB in database?

Igor Korot
Hi, Richard,
Thank you for the reply.

On Sun, Jun 9, 2019 at 7:24 PM Richard Hipp <[hidden email]> wrote:
>
> On 6/9/19, Igor Korot <[hidden email]> wrote:
> >
> > Now I open this database in sqlite3 CLI binary and would like to insert some
> > png
> > file inside this BLOB field.
>
>
> INSERT INTO tab1(blob1) VALUES(readfile('some.png'));

I presume the file extension can be anything?
Looking at the documentation:

https://sqlite.org/cli.html

this looks to be the case.

Thank you.


>
> --
> D. Richard Hipp
> [hidden email]
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How to insert the BLOB in database?

Simon Slavin-3
On 9 Jun 2019, at 2:24pm, Igor Korot <[hidden email]> wrote:

>> INSERT INTO tab1(blob1) VALUES(readfile('some.png'));
>
> I presume the file extension can be anything?

As you presume, the SQLite extension does not understand the contents of the file.  It's treated just as a sequence of octets.  So you can use this extension to read files of any type you wish, including SQLite databases.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How to insert the BLOB in database?

Mark Halegua
In reply to this post by Richard Hipp-3
On Sunday, June 09, 2019 08:24:10 PM Richard Hipp wrote:
> On 6/9/19, Igor Korot <[hidden email]> wrote:
> > Now I open this database in sqlite3 CLI binary and would like to insert
> > some png
> > file inside this BLOB field.
>
> INSERT INTO tab1(blob1) VALUES(readfile('some.png'));

I probably should figure this out, but in a GUI, how do I recover a graphic
from the database?  I can see how it's easily saved in a database field.

MaRK


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

Re: How to insert the BLOB in database?

Simon Slavin-3
On 10 Jun 2019, at 3:44am, Mark Halegua <[hidden email]> wrote:

> I probably should figure this out, but in a GUI, how do I recover a graphic from the database?

Programming.  SQLite can't do it since it doesn't even understand that that sequence of octets is a graphics.

How you do it in programming depends on your development environment and libraries.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How to insert the BLOB in database?

Mark Halegua
On Monday, June 10, 2019 03:46:02 AM Simon Slavin wrote:

> On 10 Jun 2019, at 3:44am, Mark Halegua <[hidden email]> wrote:
> > I probably should figure this out, but in a GUI, how do I recover a
> > graphic from the database?
> Programming.  SQLite can't do it since it doesn't even understand that that
> sequence of octets is a graphics.
>
> How you do it in programming depends on your development environment and
> libraries. _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

I'm using Python.  What would the programming sequence be to display the graphic in
that language?

Mark

mARK


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

Re: How to insert the BLOB in database?

Simon Slavin-3
On 10 Jun 2019, at 4:08am, Mark Halegua <[hidden email]> wrote:

> I'm using Python.  What would the programming sequence be to display the graphic in that language?

It's not a SQlite question.  SQLite doesn't understand graphics.  You'd do it similar to how you'd display a graphic you'd read from a file.  Google it, or ask on a Python forum.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: How to insert the BLOB in database?

Luuk
In reply to this post by Mark Halegua

On 10-6-2019 05:08, Mark Halegua wrote:

> On Monday, June 10, 2019 03:46:02 AM Simon Slavin wrote:
>> On 10 Jun 2019, at 3:44am, Mark Halegua <[hidden email]> wrote:
>>> I probably should figure this out, but in a GUI, how do I recover a
>>> graphic from the database?
>> Programming.  SQLite can't do it since it doesn't even understand that that
>> sequence of octets is a graphics.
>>
>> How you do it in programming depends on your development environment and
>> libraries. _______________________________________________
>> sqlite-users mailing list
>> [hidden email]
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> I'm using Python.  What would the programming sequence be to display the graphic in
> that language?
>
> Mark
>
> mARK

google for:  python show picture from database sqlite

https://stackoverflow.com/questions/30818728/retrieve-image-from-sqlite3-database-and-directly-display-on-kivy-window


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

Re: How to insert the BLOB in database?

FarSight Data Systems
Thank you.

Mark


On Monday, June 10, 2019 12:53:29 PM Luuk wrote:
> On 10-6-2019 05:08, Mark Halegua wrote:
> > On Monday, June 10, 2019 03:46:02 AM Simon Slavin wrote:
> >> On 10 Jun 2019, at 3:44am, Mark Halegua <[hidden email]>
wrote:

> >>> I probably should figure this out, but in a GUI, how do I recover a
> >>> graphic from the database?
> >>
> >> Programming.  SQLite can't do it since it doesn't even understand that
> >> that
> >> sequence of octets is a graphics.
> >>
> >> How you do it in programming depends on your development environment and
> >> libraries. _______________________________________________
> >> sqlite-users mailing list
> >> [hidden email]
> >> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
> > I'm using Python.  What would the programming sequence be to display the
> > graphic in that language?
> >
> > Mark
> >
> > mARK
>
> google for:  python show picture from database sqlite
>
> https://stackoverflow.com/questions/30818728/retrieve-image-from-sqlite3-dat
> abase-and-directly-display-on-kivy-window
> > _______________________________________________
> > sqlite-users mailing list
> > [hidden email]
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

--
------------------------
Mark S. Halegua
718-360-1712
917-686-8794
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users