Store png/pdf file in sqlite [duplicate] - iphone

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Reading and writing images to an SQLite DB for iPhone use
How to store pdf,png file in sqlite.
is this possible to store pdf and png file?
Please help me out.
if you have any idea please share with me.
Thanks you,

There is a BLOB data type so I guess you can:
http://www.sqlite.org/datatype3.html

You can store a PDF or PNG file in a BLOB field.
first create the table
create table Blubber ( PK int primary key , BITSINK blob );
then use insert to add the data.
insert into Blubber (PK,BITSINK)
values (1, 'your blob goes here, best to use bind variables though!');
Tell us what language you are using for advice how to use bind variable.
EDIT just saw this is taged iPhone, the language would be the appropriate C dialect (objective c??)

Related

Db2 for I: Cpyf *nochk emulation

In the IBM i system there's a way to copy a from a structured file to one without structure using Cpyf *nochk.
How can it be done with sql?
The answer may be "You can't", not if you are using DDL defined tables anyway. The problem is that *NOCHK just dumps data into the file like a flat file. Files defined with CRTPF, whether they have source, or are program defined, don't care about bad data until read time, so they can contain bad data. In fact you can even read bad data out of a file if you use a program definition for that file.
But, an SQL Table (one defined using DDL) cannot contain bad data. No matter how you write it, the database validates the data at write time. Even the *NOCHK option of the CPYF command cannot coerce bad data into an SQL table.
There really isn't an easy way
Closest would be to just build a big character string using CONCAT...
insert into flatfile
select mycharfld1
concat cast(myvchar as char(20))
concat digits(zonedFld3)
from mytable
That works for fixed length, varchar (if casted to char) and zoned decimal...
Packed decimal would be problematic..
I've seen user defined functions that can return the binary character string that make up a packed decimal...but it's very ugly
I question why you think you need to do this.
You can use QSYS2.QCMDEXC stored procedure to execute OS commands.
Example:
call qsys2.qcmdexc ( 'CPYF FROMFILE(QTEMP/FILE1) TOFILE(QTEMP/FILE2) MBROPT(*replace) FMTOPT(*NOCHK)' )

How to store and retrieve image in orientdb using java?

Hi I am new to OrientDB and I search about this in google and I could find this.
http://orientdb.com/docs/last/Binary-Data.html.
May be this question is not a valid but I have a doubt what will be type of element which will store binary data.
1.if we are trying to save image as Schema Full property?
2 if we are trying to save image as Schema less property?
As mentioned in above document.
ODocument doc = new ODocument();
doc.field("binary", "Binary data".getBytes());
doc.save();
where will 'doc' will get saved?
Would it possible to give some example on how to save image/binary data and retrieve it.
They binary data type for binary types is OType.BINARY
If you don't specify a class for the document, it will be saved in the "default" cluster. Then you can query it with SELECT FROM cluster:default WHERE ...
BUT I strongly discourage you from doing it, please also consider that in v 3.0 automatic save to the default cluster no longer supported (but you can still do doc.save("default") explicitly)
In general it's much better to create a specific class and save your docs there, eg.
//create the schema only the first time of course
OClass class = db.getMetadata().getSchema().createClass("Image");
class.createProperty("binary", OType.BINARY); // if you want it schemaful
ODocument doc = db.newInstance("Image")
doc.field("binary", "Binary data".getBytes());
doc.save();

whats the use of storing image name while saving image into bytea column in postgresql?

I am storing images into bytea column in postgresql my doubt is there any use if i store the file name example(tree.jpeg) into DB. Anyhow i'm able to display images in jsp which are stored in bytea column without its file name. so whats the use of storing file name of the images in DB?
There is no reason whatsoever to store the file name, unless you intend to store the image back in the file system under it's original name at some point.

Is it possible to Import a SIngle table(with data) from the whole database.sql file ? [duplicate]

This question already has answers here:
Can I restore a single table from a full mysql mysqldump file?
(20 answers)
Closed 6 years ago.
I have a dump file of memory >1.0GB. It seems highly impossible to edit to take only few tables with structure and data.
I know that exporting with only perticualr table.
But, Is it possible to import only some table with "mysqldump" import and export query ?
You can try importing the whole DB and exporting the table(s) that you need, and then importing them again to a new DB.

how to create a PostgreSQL table from a XML file...

I have a XML Document file. The part of the file looks like this:
-<attr>
<attrlabl>COUNTY</attrlabl>
<attrdef>County abbreviation</attrdef>
<attrtype>Text</attrtype>
<attwidth>1</attwidth>
<atnumdec>0</atnumdec>
-<attrdomv>
-<edom>
<edomv>C</edomv>
<edomvd>Clackamas County</edomvd>
<edomvds/>
</edom>
-<edom>
<edomv>M</edomv>
<edomvd>Multnomah County</edomvd>
<edomvds/>
</edom>
-<edom>
<edomv>W</edomv>
<edomvd>Washington County</edomvd>
<edomvds/>
</edom>
</attrdomv>
</attr>
From this XML file, I want to create a PostgreSQL table with columns of attrlabl, attrdef, attrtype, and attrdomv. I appreciate your suggestions!
While Erwin is right that this can be done with PostgreSQL tools, I would suggest still going the custom translation yourself as there are a few reasons here.
The first is determining appropriate XML to PostgreSQL type conversions. You probably want to choose these yourself. But this example highlights a very different problem, what to do with nested data structures. You could, for example, store XML fragments. You could store text, json, or the like. You could create other tables and fkey in.
In general I have almost always found the best approach is to simply manually create the tables. This substitutes human judgement for automated mappings and allows you to create better matches than a computer will.