Skip to content

Instantly share code, notes, and snippets.

@joscdk joscdk/test.swift Secret
Last active Jan 16, 2019

Embed
What would you like to do?
#!/usr/bin/swift sh
import PostgreSQL // https://github.com/vapor/postgresql.git ~> 1.0.0
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
struct VersionMetadata: Codable {
var version: String
}
let client = try PostgreSQLConnection.connect(hostname: "localhost", port: 5432, on: group).wait()
_ = try client.authenticate(username: "vapor", database: "test", password: "password").wait()
client.logger = DatabaseLogger(database: .psql, handler: PrintLogHandler())
let results = try client.select().column(.function("version", [])).all(decoding: VersionMetadata.self).wait()
print(results[0].version)
@mxcl

This comment has been minimized.

Copy link

commented Jan 15, 2019

Could be:

import PostgreSQL  // @vapor ~> 1.0

But either works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.