vishnuvathsan / sqljet

Automatically exported from code.google.com/p/sqljet
0 stars 0 forks source link

Is it possible to create in-memory DB? #125

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

Is it possible to create in-memory database using sqljet? also if possible can 
i take a dump for the same..

Thanks,
Maulik

Original issue reported on code.google.com by maulik.g...@tcs.com on 23 Jun 2010 at 6:37

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Yes, it is. You can create database in memory using SQLJet.

There is sample:

        SqlJetDb db = new SqlJetDb(SqlJetDb.IN_MEMORY, true);
        db.open();
        try {
            final ISqlJetTableDef tDef = db.createTable("create table t(a integer primary key, b text);");
            final ISqlJetTable t = db.getTable(tDef.getName());
            t.insert(null, "hello");
            t.insert(null, "world");
            db.runReadTransaction(new ISqlJetTransaction() {
                public Object run(SqlJetDb db) throws SqlJetException {
                    final ISqlJetCursor c = t.open();
                    try {
                        while (!c.eof()) {
                            Logger.global.info(String.format("#%d: \"%s\"", c.getInteger("a"), c.getString("b")));
                            c.next();
                        }
                    } finally {
                        c.close();
                    }
                    return null;
                }
            });
        } finally {
            db.close();
        }

Original comment by sergey.s...@gmail.com on 28 Jun 2010 at 7:20

GoogleCodeExporter commented 8 years ago
See too at http://code.google.com/p/sqljet/wiki/InMemoryDb

Original comment by sergey.s...@gmail.com on 28 Jun 2010 at 7:28

GoogleCodeExporter commented 8 years ago
Thanks!! 
Is it possible to take a dump of the same. Or can I put the in_memory DB into a 
byte stream??

Thanks a lot!

Original comment by maulik.g...@tcs.com on 29 Jun 2010 at 4:21

GoogleCodeExporter commented 8 years ago
In theory it is possible but we haven't tried yet :)

For that you must use low-level inner interfaces which are accessible only as 
protected members. You could define your own ancestor of SqlJetDb class and use 
inherited member

protected ISqlJetBtree btree;

that member has own member

ISqlJetPager getPager() throws SqlJetException;

which has

ISqlJetFile getFile();

which has methods

   int read(final ISqlJetMemoryPointer buffer, final int amount, final long offset) throws SqlJetIOException;

and

    void write(final ISqlJetMemoryPointer buffer, final int amount, final long offset) throws SqlJetIOException;

If you want then we could write some solution for you if you will define more 
details about your requirements.

Original comment by sergey.s...@gmail.com on 29 Jun 2010 at 4:45

GoogleCodeExporter commented 8 years ago
My requirement is something like this :
I am creating an in-memory DB and without using any IO libraries I want to get 
the dump of the created Database. Hence instead of writing to a file I want to 
write it in Byte Stream. Hence the output that I get is a byte stream of the 
same file that would be normally created.

Thanks,
Maulik

Original comment by maulik.g...@tcs.com on 29 Jun 2010 at 4:50

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
OK. We would include this feature in our next coming-soon minor release.

If you want get non-GPL commercial license, please contact us at 
support@sqljet.com.

Thanks you. If you have some other questions we will glad to answer.

Original comment by sergey.s...@gmail.com on 29 Jun 2010 at 5:07

GoogleCodeExporter commented 8 years ago
I'll notify you in this issue, when we will be releasing a complete solution 
for your request. It will also be open source as a whole SQLJet is. :)

Original comment by sergey.s...@gmail.com on 29 Jun 2010 at 5:18

GoogleCodeExporter commented 8 years ago
And yet, perhaps we will have any additional questions you according to your 
requirements. 

Currently I would like to clarify if you need only read the data into a stream, 
or you should just write data from the stream into live in-memory database?

Original comment by sergey.s...@gmail.com on 29 Jun 2010 at 5:29

GoogleCodeExporter commented 8 years ago
Would you write to open in-memory database directly from stream?

Or you want get only snapshot dump from database into stream and no more, as 
you have described?

May be you want restore database from stream?

Original comment by sergey.s...@gmail.com on 29 Jun 2010 at 5:33

GoogleCodeExporter commented 8 years ago
Could you tell me, what is the situation with this case, please?

Original comment by tuomas.k...@gmail.com on 14 Feb 2012 at 2:05

GoogleCodeExporter commented 8 years ago
#5 I tried this and it doesn't work.

I have a similar case where I want to create a SQLite file using Google 
AppEngine. I do not have access to a file system. I want to send the "file" to 
my IOS Application and use it there.
I have no need for the other way around. Taking a stream and make it into an 
in-memory structure.
Would be very happy for an update of the topic.

Original comment by ronnie.b...@mtgx.se on 6 Aug 2014 at 3:25

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
So, is it now possible to get a stream from the in-memory DB (I just want a 
dump) to stream over http.

Original comment by j...@foreflight.com on 18 Mar 2015 at 3:04