Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kristiankime/5831162 to your computer and use it in GitHub Desktop.
Save kristiankime/5831162 to your computer and use it in GitHub Desktop.
A quick example of how to load a CSV file via slick and then print the contents using Slick's raw SQL commands.
object SimpleExample {
def main(args: Array[String]) {
Database.forURL("jdbc:h2:mem:working_data;DB_CLOSE_DELAY=-1", driver = "org.h2.Driver") withSession {
Q.updateNA("CREATE TABLE DATA_TABLE AS SELECT * FROM CSVREAD('data/data.csv');").execute
Q.queryNA("SELECT * FROM DATA_TABLE")(GetResult(r => (r.nextString, r.nextString, r.nextString))).foreach(println(_))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment