Skip to content

Instantly share code, notes, and snippets.

@codemwnci
Created August 25, 2017 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codemwnci/97cb0db70b2d4078fa315c3a041226e3 to your computer and use it in GitHub Desktop.
Save codemwnci/97cb0db70b2d4078fa315c3a041226e3 to your computer and use it in GitHub Desktop.
DB Setup
package codemwnci
import spark.Spark.*
import kotliquery.*
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import java.time.LocalDateTime
fun main(args: Array<String>) {
setupDB()
}
fun setupDB() {
HikariCP.default("jdbc:h2:mem:todo", "user", "pass")
// when using in memory DB, create the DDL
using(sessionOf(HikariCP.dataSource())) { session ->
session.run(queryOf("""
create table todo (
id serial not null primary key,
text varchar(255),
done boolean default false,
created_at timestamp not null default now()
)
""").asExecute) // returns Boolean
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment