the name that gets passed is the one you pass to sqlite_open... so just use
that as an indicator of which object to use and in the open callback,
result with the appropriate object....... or don't use the name and ignore
it....?  snprintf( somebuf, sizeof( somebuf ) / sizeof( somebuf[0] ), "%p",
your_file_descriptor ); sqlite3_open( somebuf ) ?


On Tue, May 13, 2014 at 4:43 AM, Ralf <[email protected]>wrote:

> Hello,
>
> I would like to use SQLite in my C++(11) project.
>
> Assume that there is a class File which is able to store arbitrary data.
> It provides basic IO functionality read() write() truncate() and sync().
>
> Now I would like to use my File to store SQLite databases (persistently).
>
> To understand my motivation, let me explain in short words what exactly
> File does:
> A "File" splits its content into several fixed-sized encrypted blocks
> and stores those blocks on some kind of storage.
> At any point in time, it is guaranteed, that no other process will
> interfere and use those blocks, so we don't need any locking mechanisms.
>
> The easiest way to implement this would be to store the whole database
> in a local temporary folder using unix vfs, close it, read all its
> content and call my file->write() routine.
> This strategy contains some ugliness as I would like to avoid using
> temporary files.
>
> So I had a deeper look into SQLite's VFS[1] interface and I think that
> it could possibly offer a better solution.
>
> Now my problem:
>
> There may be several File objects, each representing a SQLite database.
> Those objects exist before SQLite accesses them - so there is no need,
> that SQLite generates those objects.
>
> How can I use VFS to work with those objects?
>
> Generally sqlite3_open*() is used to generate a struct sqlite3*
> regarding a certain kind of VFS type.
> But I can not use sqlite3_open*() in order to "open" a File as
> sqlite3_open*() makes use of a const char* filename that obviously
> indicates the filename :-)
> In my case, there is nothing like a filename but there is already an
> object on which SQLite shall work with.
>
> So I would need sth. like:
>
> File *f = ...;
> sqlite3_open(f, myOwnVFSDescriptor);
>
> Are there any possibilities to solve this problem?
> Or would it be better to create a temporary SQLite database file and
> copy its content afterwards?
>
> One last question:
> I also read about in memory and temporary databases [2].
>
> Do in memory databases have the same structure as database files?
> If so, is it possible to dump and load in memory databases? (this could
> also offer a nice solution)
>
> [1] http://sqlite.org/vfs.html
> [2] http://sqlite.org/inmemorydb.html
>
> Regards and thanks!
>   Ralf
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to