Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. object Main {
  2.  
  3. class Users(tag: Tag) extends Table[(Int, String, String)](tag, "users") {
  4. def id = column[Int]("id")
  5.  
  6. def username = column[String]("username")
  7.  
  8. def miestas = column[String]("miestas")
  9.  
  10. def * = (id, username, miestas)
  11. }
  12.  
  13. def main(args: Array[String]): Unit = {
  14.  
  15. val connectionUrl = "jdbc:postgresql://localhost/test?user=postgres&password=kurmis"
  16.  
  17. Database.forURL(connectionUrl, driver = "org.postgresql.Driver") withSession {
  18. implicit session =>
  19. val users = TableQuery[Users]
  20.  
  21. for (a <- 1 to 10) {
  22. val r = scala.util.Random
  23. users.map(_.username) += r.nextInt.toString
  24.  
  25. }
  26.  
  27. //Insert
  28. val r = scala.util.Random
  29. users.map(_.username) += r.nextInt.toString
  30. println("pabandom")
  31.  
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement