From 4128b03e2b433b4c2f3687365cb8faf8c229fbd1 Mon Sep 17 00:00:00 2001 From: rightfold Date: Thu, 22 Dec 2016 20:28:47 +0100 Subject: [PATCH] Add command line parameter to purspgpp --- PurspgppExample.purs | 11 +++++++++++ purspgpp | 18 ++---------------- 2 files changed, 13 insertions(+), 16 deletions(-) create mode 100644 PurspgppExample.purs diff --git a/PurspgppExample.purs b/PurspgppExample.purs new file mode 100644 index 0000000..3e9f600 --- /dev/null +++ b/PurspgppExample.purs @@ -0,0 +1,11 @@ +module PurspgppExample where + +f :: Query (String × Unit) (UUID × String × Unit) +f = [query| + SELECT id, name + FROM files + WHERE author_id = $1 +|] + +g :: Query Unit (Boolean × Unit) +g = [query|SELECT pg_try_advisory_lock(3735928559)|] diff --git a/purspgpp b/purspgpp index 2897782..780242a 100644 --- a/purspgpp +++ b/purspgpp @@ -75,21 +75,7 @@ sub process-query($conn, Str:D $source) { "(Query \"\"\"$source\"\"\" :: Query ($parameters) ($fields))"; } -sub MAIN { +sub MAIN(IO(Cool) $filename) { my $conn = libpq::Connection.new("user=postgres password=lol123 dbname=nn"); - - print process-module($conn, $=finish); + print process-module($conn, $filename.slurp); } - -=finish -module M where - -f :: Query (String × Unit) (UUID × String × Unit) -f = [query| - SELECT id, name - FROM files - WHERE author_id = $1 -|] - -g :: Query Unit (Boolean × Unit) -g = [query|SELECT pg_try_advisory_lock(3735928559)|]