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("mickey@mouse.com", "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", "daisy@duck.com")
two <- prep.exec("Minnie Mouse", "ms.mouse@mouse.com")
} 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='mickey@mouse.com'")
res <- prep.exec("Mr. Michael Mouse", "mr.mouse@mouse.com")
} 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