score:0
the below one generated slick code for tables from the selected schema:
object customcodegenerator extends app {
val url = "jdbc:oracle:thin:@//localhost:1521/xe"
val jdbcdriver = "oracle.jdbc.oracledriver"
val username = "user"
val password = "password"
val db = oracledriver.api.database.forurl(url, user = username, password = password, driver = jdbcdriver)
// filter out desired tables
val requiredtables = seq("br_fld", "fld_gm_sdo", "br_rep", "plt_gm_sdo")
// filter out desired schema
val requiredschema = seq("plot")
val codegen = db.run {
oracledriver.defaulttables
.map(_.filter(p => requiredtables.contains(p.name.name.tolowercase) && requiredschema.contains(p.name.schema.get.tolowercase)))
.flatmap(oracledriver.createmodelbuilder(_, false).buildmodel)
}
.map { model =>
new slick.codegen.sourcecodegenerator(model) {
override def entityname = dbtablename => dbtablename match {
case _ => super.entityname(dbtablename)
}
}
}
await.ready(
codegen.map(_.writetofile(
"com.typesafe.slick.driver.oracle.oracledriver", ".", "demo", "tables", "tables.scala")),
300.seconds
).oncomplete {
case success(value) => println("code generation done")
case failure(e) => e.printstacktrace
}
}
Source: stackoverflow.com
Related Query
- Generate code using Slick Codegen 3.1.1 for multiple schemas
- Using multiple projection in slick for the same table
- Slick code generation with multiple identical schemas
- How do you update multiple columns using Slick Lifted Embedding?
- Why does Slick require using three equal signs (===) for comparison?
- Failed to execute user defined function($anonfun$9: (string) => double) on using String Indexer for multiple columns
- Using Akka Http for Multiple Bindings
- How to organize code for multiple scala versions and differents dependencies
- Can sbt-native-packager generate multiple start scripts for one project?
- Slick 3.3.3 Filter table using `.inSet` on multiple columns
- In scala, how to generate boilerplate code for parameter list of different length?
- Multiple parameters in where clause using Slick 2
- Slick code generation for only a single schema
- Compile error using slick MappedColumnType for static query
- how to generate new column values for each group using a condition
- How to generate OR queries in .where() clause using Scala Slick 2.0?
- How can I view the code that Scala uses to automatically generate the apply function for case classes?
- Defining Test Data for Java Code - Simply - perhaps using Scala?
- Setting up actions for multiple test folders in SBT using 'Simple' configuration
- Does it make sense to use Paging SQL Statement when using Slick (JDBC) Connector for Alpakka
- Slick 2.1 Code generator for MySQL : ClassNotFoundException on driver
- For yield with Rep[Optional[...]] using Slick
- Using a separate ExecutionContext for Slick
- What's the syntax for multiple dependency injection using Spring and Scala?
- Generate scala source for a class instance using reflection
- Use casesĀ for using multiple queries for Spark Structured streaming
- Script uses same name everytime for multiple requests instead of using different name per request
- Errors with using Scalaxb for code generation
- Error when using slick code generator on postgres with uuid_generate_v4()
- How to write a global object for table creation using Slick MultiDBCake principle?
More Query from same tag
- Scala trait: How to require output parameter to be Numeric: ambiguous implicit values error
- SBT Scaladoc Configuration
- Gatling - Scala extract substring
- Spark dataframe filter
- Insert an element between each two adjacent elements of Seq
- How to read simple text file from Google Cloud Storage using Spark-Scala local Program
- Count occurrences of each element in a List[List[T]] in Scala
- how to create and download a file using play framework?
- Scala - Nested loops, for-comprehension and type of the final iteration
- Why does the type conversion from Class[String] to Class[Any] compile successfully?
- Error when downloading dependencies for org.apache.hive.hive-exec version 1.2.1
- Why can't I link to one template from another?
- Expression of type Any doesn't conform to expected type_$1
- No implicit view available from K => Ordered[K]. Error occurred in an application involving default arguments
- Unclear compilation info seqDerivedOrdering is not a valid implicit value for scala.math.Ordering[W]
- Improvement of State Machine implemented in scala
- Invoke a Scala Function2 with a shapeless HList whose values do not match the argument order
- How to wait for Akka actor system to terminate?
- implementing a trait with a type parameter def fails to compile
- Read JSON Tree structure in Scala Play Framework
- Scala - Optional Predicate
- akka 2.2.0 Scala 2.11 "message was not delivered" - unless using Thread.sleep(50)
- Type mismatch when using Scala case class constructor as a method call
- Could not find implicit format for parameter
- Applying a map function on Dataframe will convert into an RDD everytime?
- Scala Remote Actors - Pitfalls
- In Anorm is it possible to apply multiple ColumnAliaser to the same query
- Summary/reference documentation on Scala standard library types
- Scala huffman decoding
- No implicit Ordering defined for T with Int (Scala)