SQLite3 Phobos branch

Robert Clipsham robert at octarineparrot.com
Sun Apr 24 15:49:16 PDT 2011


On 24/04/2011 21:40, dsimcha wrote:
> However, it seems others in the community are interested in a more
> general SQL DB wrapper that can be used with a variety of backends.
> Now that no GSoC database project has been accepted, we need to
> consider other options for getting this done. I understand that there
> are a lot of independent attempts, but I don't know the status of
> them or which ones, if any, are targeting eventual inclusion in
> Phobos.

I have a general SQL db wrapper (only wrapping SQLite currently), which 
I'd be happy to adapt and submit for phobos, I'm currently working on a 
complete rewrite though, so this may not be a great idea right now.

Example usage:
----
struct Post
{
     int id;
     DateTime time;
     string title;
     string content;
}

auto getPosts(long lim, long offs=0)
{
     with (new SqlQuery)
     {
         select("*").from("blog")
                    .limit(lim)
                    .offset(offs);
         return execute!(Post)();
     }
}
foreach(post; getPosts(10))
{
     // Operate on posts
}
----

The new interface makes the above even simpler, it will look something 
like (rather rough, I'm in the early stages of implementing it):
----
struct Post
{
     int id;
     DateTime time;
     string title;
     string content;
}

auto posts = new SqlitePersister!Post(new SqliteDb("my.db"));
foreach(post; posts[0..10])
{
     // Operate on posts
}
----

Of course, both of these provide (or will provide) an interface to allow 
for SQL statements to be executed directly.

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d mailing list