Created
July 15, 2015 23:33
-
-
Save will/9a99d15fca18e521c38f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@[Link(ldflags: "-lpq -I`pg_config --includedir` -L`pg_config --libdir`")] | |
lib LibPQ | |
fun connect = PQconnectdb(conninfo : UInt8*) : Void* | |
fun exec = PQexec(conn : Void*, query : UInt8*) : Void* | |
fun getvalue = PQgetvalue(res : Void*, row : Int32, column : Int32) : UInt8* | |
end | |
conn = LibPQ.connect("postgres:///") | |
res = LibPQ.exec(conn, "select 'Hello it is ' || now()") | |
String.new(LibPQ.getvalue(res, 0, 0)) #=> "Hello it is 2015-07-15 16:30:44.396092-07" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment