any info about inline sqlite?

7 views
Skip to first unread message

mqualls

unread,
Jun 4, 2018, 5:38:16 PM6/4/18
to bpipe-discuss
0.9.9.3 references experimental support for inline sql, but I can't find any info about syntax or anything

Simon Sadedin

unread,
Jun 4, 2018, 5:59:14 PM6/4/18
to bpipe-discuss on behalf of mqualls
It stayed kind of experimental as I found although it was neat, I still found it better to write actual code to insert into the database rather than inline SQL in pipelines. But that was partly because my case was a bit more complex - there could be uses where that is not true. Here is an example (albeit kind of silly) of how it can be used:

hello = {
    sqlite "$output.db", """
        create table person (name varchar(50), age integer);
    """
}

there = {
    exec """
        echo bob > $output.txt
    """
}

world = {
    sqlite input.db,"""
        insert into person values ('${file(input.txt).text.trim()}',50);
        insert into person values ('andrew',42);
    """

}

run { 
    hello + there + world
}

This is up against just adding direct DB calls in your bpipe script which is easily possible:

@Grab(group='org.xerial', module='sqlite-jdbc', version='3.23.1')

db = groovy.sql.Sql.newInstance('jdbc:sqlite:test.db')

hello = {
    db.execute("""
        create table person (name varchar(50), age integer);
    """)
}

run { hello }


Of course, this second version creates the database directly in the pipeline script, so it will not be submitted as a job to a cluster or get the benefit of any of bpipe's other features (command monitoring, capture of output, etc). If you find it useful and give it some testing it can certainly become an "official" feature.

Cheers,

Simon



On Fri, Jun 1, 2018 at 8:42 AM, mqualls via bpipe-discuss <bpipe-discuss+APn2wQdi5Zzvlv1bJ6...@googlegroups.com> wrote:
0.9.9.3 references experimental support for inline sql, but I can't find any info about syntax or anything

--
You received this message because you are subscribed to the Google Groups "bpipe-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bpipe-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to bpipe-...@googlegroups.com.
Visit this group at https://groups.google.com/group/bpipe-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages