Slick is the Scala database access library launched by TypeSafe. Developers can use the Scala language to write data queries, rather than SQL. Example code: packagecom. testimportscala. slick. driver. MySQLDriver. simple. _ importcom. mysql. jdbc. jdbc2.optional. MysqlDataSourceimportscala
Slick is the Scala database access library launched by TypeSafe. Developers can use the Scala language to write data queries instead of SQL statements. Example code: package com. testimport scala. slick. driver. mySQLDriver. simple. _ import com. mysql. jdbc. jdbc2.optional. mysqlDataSourceimport scala
Slick is the Scala database access library launched by TypeSafe. Developers can use the Scala language style to write data queries, rather than SQL. Example code:
Package com. testimport scala. slick. driver. mySQLDriver. simple. _ import com. mysql. jdbc. jdbc2.optional. mysqlDataSourceimport scala. slick. session. databaseimport scala. slick. session. sessionobject Supplier extends Table [(String, Int)] ("test") {def name = column [String] ("name ") def age = column [Int] ("age") def * = name ~ Agedef main (args: Array [String]) {val session = Sandbox. databaseval query = tableToQuery (Supplier) // query. selectStatement // query. foreach (println (_) (session) // update // val uq = Supplier. filter (p => p. name = "ricki "). map (_. age) /// uq. updateStatement // uq. update (24) (session) // insert // val in = Supplier. name ~ Supplier. age /// in. insertStatement // in. insert ("cherry", 1) (session) // Delete val dq = Supplier. filter (_. name = "cherry") dq. deleteStatementdq. delete (session) session. close} object Sandbox {def database: Session = {val dataSource = new MysqlDataSource () dataSource. setUser ("root") dataSource. setPassword ("root") dataSource. setDatabaseName ("test") val dataBase = Database. forDataSource (dataSource) dataBase. createSession }}
For more information, see the official website: http://slick.typesafe.com/docs/
Official third-party Tutorial: http://mackler.org/LearningSlick/#id11540725