Postgres database support for finagle.
Maven
<repositories>
<repository>
<id>com.github.mairbek</id>
<url>https://raw.github.com/mairbek/mvn-repo/master/</url>
<layout>default</layout>
</repository>
</repositories>
<dependency>
<groupId>com.github.mairbek</groupId>
<artifactId>finagle-postgres_2.9.2</artifactId>
<version>0.0.2</version>
<scope>compile</scope>
</dependency>
sbt
resolvers += "com.github.mairbek" at "https://raw.github.com/mairbek/mvn-repo/master"
"com.github.mairbek" % "finagle-postgres" % "0.0.2"
val client = Client(host, username, password, database)
val f = client.select("select * from users") {row =>
User(row.getString("email"), row.getString("name"))
}
logger.debug("Responded " + f.get)
val f = for {
prep <- client.prepare("select * from users where email=$1 and name=$2")
users <- prep.select("[email protected]", "Mickey Mouse") {
row => User(row.getString("email"), row.getString("name"))
}
} yield users
logger.debug("Responded " + f.get)
val f = for {
prep <- client.prepare("insert into users(email, name) values ($1, $2)")
one <- prep.exec("Daisy Duck", "[email protected]")
two <- prep.exec("Minnie Mouse", "[email protected]")
} yield one.affectedRows + two.affectedRows
logger.debug(f.get + " rows affected")
val f = for {
prep <- client.prepare("update users set name=$1, email=$2 where email='[email protected]'")
res <- prep.exec("Mr. Michael Mouse", "[email protected]")
} yield res.affectedRows
logger.debug(f.get + " rows affected")
- Prepared statements support
- Async responses logging
- Exceptions handling
- Create table/Drop table support
- Clear text authentication support
- Md5 authentication support
- Select, update, insert and delete queries