本文整理汇总了Scala中slick.jdbc.JdbcBackend.Database类的典型用法代码示例。如果您正苦于以下问题:Scala Database类的具体用法?Scala Database怎么用?Scala Database使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Database类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: createSchemaWork
//设置package包名称以及导入依赖的类
package io.scalac.wtf.domain
import cats.data.Reader
import slick.jdbc.JdbcBackend.Database
import slick.lifted.TableQuery
import slick.driver.H2Driver.api._
import io.scalac.wtf.domain.tables.Users
trait DatabaseDependancy {
val db = Database.forConfig("h2mem1")
//Used for showcase only, the table should already exist in a realistic scenario
def createSchemaWork = Reader((config: Config) =>
{
implicit val ec = config.ec
for {
_ <- TableQuery[Users].schema.create
} yield ()
}
)
}
开发者ID:ScalaConsultants,项目名称:whisky-tango-foxtrot,代码行数:23,代码来源:DatabaseDependancy.scala
示例2: MysqlDBConnection
//设置package包名称以及导入依赖的类
package db
import slick.driver.JdbcProfile
import slick.backend.DatabaseConfig
import slick.jdbc.JdbcBackend.Database
trait DBConnectionComponent {
val dbConnection: DBConnection
class MysqlDBConnection extends DBConnection {
lazy val profile = slick.driver.MySQLDriver
lazy val config:String = "default"
lazy val dc = DatabaseConfig.forConfig[JdbcProfile](config)
}
}
trait DBConnection {
val dc: DatabaseConfig[JdbcProfile]
val profile: slick.driver.JdbcProfile
val db = dc.db
}
开发者ID:sushanttal,项目名称:BookSharing,代码行数:24,代码来源:DBConnection.scala
示例3: getPostSummaries
//设置package包名称以及导入依赖的类
package docs.home.scaladsl.persistence
import akka.NotUsed
//#imports
import com.lightbend.lagom.scaladsl.api.{Service, ServiceCall}
import slick.jdbc.JdbcBackend.Database
//#imports
import docs.home.scaladsl.persistence.SlickRepos.Initial.PostSummaryRepository
trait SlickReadSideQuery {
trait BlogService extends Service {
def getPostSummaries(): ServiceCall[NotUsed, Seq[PostSummary]]
override def descriptor = ???
}
//#service-impl
class BlogServiceImpl(db: Database, val postSummaryRepo: PostSummaryRepository) extends BlogService {
override def getPostSummaries() = ServiceCall { request =>
db.run(postSummaryRepo.selectPostSummaries())
}
//#service-impl
}
}
开发者ID:lagom,项目名称:lagom,代码行数:27,代码来源:SlickReadSideQuery.scala
示例4: Remove
//设置package包名称以及导入依赖的类
package spider.cli
package command
import spider.Util.{ errorExit }
import spider.cli.CLI._
import spider.cli.Args._
import spider.database._
import spider.database.FarmDB.SyncDB
import com.github.nscala_time.time.Imports._
import slick.jdbc.JdbcBackend.Database
object Remove {
case class RemoveArgs(
dates: Args[IndexedSeq[DateTime]] = DatesArg(),
config: Args[DBConfig] = ConfigArg())
def parseArgs(args: Seq[String]): RemoveArgs = {
@annotation.tailrec
def parseArgsImpl(
acc: RemoveArgs, rest: Seq[String]): RemoveArgs = rest match {
case e if rest.isEmpty ? acc
case acc.dates.update(dates, next) ?
parseArgsImpl(acc.copy(dates = dates), next)
case acc.config.update(config, next) ?
parseArgsImpl(acc.copy(config = config), next)
case other +: tail ? errorExit(s"unknown option $other")
}
parseArgsImpl(RemoveArgs(), args)
}
def remove(db: Database, dates: Seq[DateTime]) = {
import scala.concurrent.ExecutionContext.Implicits._
db.runSync(FarmTable.clearRecordsAction(dates))
}
def apply(args: Seq[String]): Unit = {
val a = parseArgs(args)
val dates = a.dates.getOrExit
val db = FarmDB.getConnection(a.config.getOrExit)
remove(db, dates)
}
}
开发者ID:VinaLx,项目名称:farm-spider,代码行数:43,代码来源:remove.scala
示例5: MixInDB
//设置package包名称以及导入依赖的类
package net.petitviolet.infra
import slick.jdbc.JdbcBackend
import slick.jdbc.JdbcBackend.Database
trait UsesDB {
val db: JdbcBackend.DatabaseDef
}
trait MixInDB {
val db: JdbcBackend.DatabaseDef = MixInDB.db
}
// ????????????????????
private object MixInDB {
val db: JdbcBackend.DatabaseDef = Database.forConfig("mysql-local")
}
开发者ID:petitviolet,项目名称:akka-http-slick-ddd,代码行数:18,代码来源:DB.scala
注:本文中的slick.jdbc.JdbcBackend.Database类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论