Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Slick is ready to develop the environment


May 17, 2021 Slick


Table of contents


Prepare the development environment

This article describes that if you set up a Scala development environment that uses Slick, here we use the SBT command line, and SBT uses the same directory structure as Maven, where we can create a directory, such as Slick, and then create the following default directory structure:

  • Src
    • main
      • Java
      • resources
      • Scala
    • test
    • Java
    • resources
    • Scala

Because we're going to use the MySQL database and use Slick to access the database, we're creating a build.sbt at Slick's root and adding a reference:

name := "Scala Slick Examples"

version := "1.0"

scalaVersion := "2.10.4"

libraryDependencies += "com.typesafe.slick" %% "slick" % "2.0.2"

libraryDependencies += "org.slf4j" % "slf4j-nop" % "1.6.4"

libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.18"

Slick uses SLF4J as a log library file.

Our MySQL database Chinook is installed on a local server, and we can use Slick to manually create a definition of the database table Schema, or to create a Schema definition of table from an existing database using the automated code generation tool.

We enter sbt on the command line and go to the SBT console.

Then we use console, go to the Scala console, and notice that at this point SBT automatically adds libraries referenced in build.sbt, such as slick, mysql, to the Scala console, and we use the following command:

scala.slick.model.codegen.SourceCodeGenerator.main(
    Array(slickDriver, jdbcDriver, url, outputFolder, pkg, user, password)
)

The relevant parameters are as follows:

slickDriver Fully qualified name of Slick driver class, e.g. “scala.slick.driver.H2Driver”
jdbcDriver Fully qualified name of jdbc driver class, e.g. “org.h2.Driver”
url jdbc url, e.g. “jdbc:postgresql://localhost/test”
outputFolder Place where the package folder structure should be put
pkg Scala package the generated code should be places in
user database connection user name
password database connection password

For example, in this case, we use the mysql database and enter the following command on the command line: Note modifying your username and password:

scala.slick.model.codegen.SourceCodeGenerator.main(
    Array("scala.slick.driver.MySQLDriver", "com.mysql.jdbc.Driver", 
    "jdbc:mysql://127.0.0.1/Chinook", 
    "./src/main/scala",
    "com.guidebee.slick.example", "user", "password")
)

This automated code generation tool /src/main/scala directory

package com.guidebee.slick.example
// AUTO-GENERATED Slick data model
/** Stand-alone Slick data model for immediate use */
object Tables extends {
    val profile = scala.slick.driver.MySQLDriver
} with Tables

/** Slick data model trait for extension, choice of backend or usage in the cake pattern. (Make sure to initialize this late.) */
trait Tables {
    val profile: scala.slick.driver.JdbcProfile
    import profile.simple._
    import scala.slick.model.ForeignKeyAction
    // NOTE: GetResult mappers for plain SQL are only generated for tables where Slick knows how to map the types of all columns.
    import scala.slick.jdbc.{GetResult => GR}

    /** DDL for all tables. Call .create to execute. */
    lazy val ddl = Album.ddl ++ Artist.ddl ++ Customer.ddl ++ Employee.ddl ++ Genre.ddl ++ Invoice.ddl ++ Invoiceline.ddl ++ Mediatype.ddl ++ Playlist.ddl ++ Playlisttrack.ddl ++ Track.ddl

    /** Entity class storing rows of table Album
     *  @param albumid Database column AlbumId PrimaryKey
     *  @param title Database column Title 
     *  @param artistid Database column ArtistId  */
    case class AlbumRow(albumid: Int, title: String, artistid: Int)
    /** GetResult implicit for fetching AlbumRow objects using plain SQL queries */
    implicit def GetResultAlbumRow(implicit e0: GR[Int], e1: GR[String]): GR[AlbumRow] = GR{
        prs => import prs._
        AlbumRow.tupled((<<[Int], <<[String], <<[Int]))
    }
    /** Table description of table Album. Objects of this class serve as prototypes for rows in queries. */
    class Album(tag: Tag) extends Table[AlbumRow](tag, "Album") {
        def * = (albumid, title, artistid) <> (AlbumRow.tupled, AlbumRow.unapply)
        /** Maps whole row to an option. Useful for outer joins. */
        def ? = (albumid.?, title.?, artistid.?).shaped.<>({r=>import r._; _1.map(_=> AlbumRow.tupled((_1.get, _2.get, _3.get)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

        /** Database column AlbumId PrimaryKey */
        val albumid: Column[Int] = column[Int]("AlbumId", O.PrimaryKey)
        /** Database column Title  */
        val title: Column[String] = column[String]("Title")
        /** Database column ArtistId  */
        val artistid: Column[Int] = column[Int]("ArtistId")

        /** Foreign key referencing Artist (database name FK_AlbumArtistId) */
        lazy val artistFk = foreignKey("FK_AlbumArtistId", artistid, Artist)(r => r.artistid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
    }
    /** Collection-like TableQuery object for table Album */
    lazy val Album = new TableQuery(tag => new Album(tag))

    /** Entity class storing rows of table Artist
     *  @param artistid Database column ArtistId PrimaryKey
     *  @param name Database column Name  */
    case class ArtistRow(artistid: Int, name: Option[String])
    /** GetResult implicit for fetching ArtistRow objects using plain SQL queries */
    implicit def GetResultArtistRow(implicit e0: GR[Int], e1: GR[Option[String]]): GR[ArtistRow] = GR{
        prs => import prs._
        ArtistRow.tupled((<<[Int], <<?[String]))
    }
    /** Table description of table Artist. Objects of this class serve as prototypes for rows in queries. */
    class Artist(tag: Tag) extends Table[ArtistRow](tag, "Artist") {
        def * = (artistid, name) <> (ArtistRow.tupled, ArtistRow.unapply)
        /** Maps whole row to an option. Useful for outer joins. */
        def ? = (artistid.?, name).shaped.<>({r=>import r._; _1.map(_=> ArtistRow.tupled((_1.get, _2)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

        /** Database column ArtistId PrimaryKey */
        val artistid: Column[Int] = column[Int]("ArtistId", O.PrimaryKey)
        /** Database column Name  */
        val name: Column[Option[String]] = column[Option[String]]("Name")
    }
    /** Collection-like TableQuery object for table Artist */
    lazy val Artist = new TableQuery(tag => new Artist(tag))

    /** Entity class storing rows of table Customer
      *  @param customerid Database column CustomerId PrimaryKey
      *  @param firstname Database column FirstName 
      *  @param lastname Database column LastName 
      *  @param company Database column Company 
      *  @param address Database column Address 
      *  @param city Database column City 
      *  @param state Database column State 
      *  @param country Database column Country 
      *  @param postalcode Database column PostalCode 
      *  @param phone Database column Phone 
      *  @param fax Database column Fax 
      *  @param email Database column Email 
      *  @param supportrepid Database column SupportRepId  */
    case class CustomerRow(customerid: Int, firstname: String, lastname: String, company: Option[String], address: Option[String], city: Option[String], state: Option[String], country: Option[String], postalcode: Option[String], phone: Option[String], fax: Option[String], email: String, supportrepid: Option[Int])
    /** GetResult implicit for fetching CustomerRow objects using plain SQL queries */
    implicit def GetResultCustomerRow(implicit e0: GR[Int], e1: GR[String], e2: GR[Option[String]], e3: GR[Option[Int]]): GR[CustomerRow] = GR{
    prs => import prs._
    CustomerRow.tupled((<<[Int], <<[String], <<[String], <<?[String], <<?[String], <<?[String], <<?[String], <<?[String], <<?[String], <<?[String], <<?[String], <<[String], <<?[Int]))
    }
  /** Table description of table Customer. Objects of this class serve as prototypes for rows in queries. */
class Customer(tag: Tag) extends Table[CustomerRow](tag, "Customer") {
    def * = (customerid, firstname, lastname, company, address, city, state, country, postalcode, phone, fax, email, supportrepid) <> (CustomerRow.tupled, CustomerRow.unapply)
    /** Maps whole row to an option. Useful for outer joins. */
    def ? = (customerid.?, firstname.?, lastname.?, company, address, city, state, country, postalcode, phone, fax, email.?, supportrepid).shaped.<>({r=>import r._; _1.map(_=> CustomerRow.tupled((_1.get, _2.get, _3.get, _4, _5, _6, _7, _8, _9, _10, _11, _12.get, _13)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column CustomerId PrimaryKey */
    val customerid: Column[Int] = column[Int]("CustomerId", O.PrimaryKey)
    /** Database column FirstName  */
    val firstname: Column[String] = column[String]("FirstName")
    /** Database column LastName  */
    val lastname: Column[String] = column[String]("LastName")
    /** Database column Company  */
    val company: Column[Option[String]] = column[Option[String]]("Company")
    /** Database column Address  */
    val address: Column[Option[String]] = column[Option[String]]("Address")
    /** Database column City  */
    val city: Column[Option[String]] = column[Option[String]]("City")
    /** Database column State  */
    val state: Column[Option[String]] = column[Option[String]]("State")
    /** Database column Country  */
    val country: Column[Option[String]] = column[Option[String]]("Country")
    /** Database column PostalCode  */
    val postalcode: Column[Option[String]] = column[Option[String]]("PostalCode")
    /** Database column Phone  */
    val phone: Column[Option[String]] = column[Option[String]]("Phone")
    /** Database column Fax  */
    val fax: Column[Option[String]] = column[Option[String]]("Fax")
    /** Database column Email  */
    val email: Column[String] = column[String]("Email")
    /** Database column SupportRepId  */
    val supportrepid: Column[Option[Int]] = column[Option[Int]]("SupportRepId")

    /** Foreign key referencing Employee (database name FK_CustomerSupportRepId) */
    lazy val employeeFk = foreignKey("FK_CustomerSupportRepId", supportrepid, Employee)(r => r.employeeid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
}
    /** Collection-like TableQuery object for table Customer */
    lazy val Customer = new TableQuery(tag => new Customer(tag))

  /** Entity class storing rows of table Employee
   *  @param employeeid Database column EmployeeId PrimaryKey
   *  @param lastname Database column LastName 
   *  @param firstname Database column FirstName 
   *  @param title Database column Title 
   *  @param reportsto Database column ReportsTo 
   *  @param birthdate Database column BirthDate 
   *  @param hiredate Database column HireDate 
   *  @param address Database column Address 
   *  @param city Database column City 
   *  @param state Database column State 
   *  @param country Database column Country 
   *  @param postalcode Database column PostalCode 
   *  @param phone Database column Phone 
   *  @param fax Database column Fax 
   *  @param email Database column Email  */
    case class EmployeeRow(employeeid: Int, lastname: String, firstname: String, title: Option[String], reportsto: Option[Int], birthdate: Option1, hiredate: Option1, address: Option[String], city: Option[String], state: Option[String], country: Option[String], postalcode: Option[String], phone: Option[String], fax: Option[String], email: Option[String])
  /** GetResult implicit for fetching EmployeeRow objects using plain SQL queries */
    implicit def GetResultEmployeeRow(implicit e0: GR[Int], e1: GR[String], e2: GR[Option[String]], e3: GR[Option[Int]], e4: GR[Option1]): GR[EmployeeRow] = GR{
    prs => import prs._
    EmployeeRow.tupled((<<[Int], <<[String], <<[String], <<?[String], <<?[Int], <<?1, <<?1, <<?[String], <<?[String], <<?[String], <<?[String], <<?[String], <<?[String], <<?[String], <<?[String]))
}
/** Table description of table Employee. Objects of this class serve as prototypes for rows in queries. */
class Employee(tag: Tag) extends Table[EmployeeRow](tag, "Employee") {
    def * = (employeeid, lastname, firstname, title, reportsto, birthdate, hiredate, address, city, state, country, postalcode, phone, fax, email) <> (EmployeeRow.tupled, EmployeeRow.unapply)
    /** Maps whole row to an option. Useful for outer joins. */
    def ? = (employeeid.?, lastname.?, firstname.?, title, reportsto, birthdate, hiredate, address, city, state, country, postalcode, phone, fax, email).shaped.<>({r=>import r._; _1.map(_=> EmployeeRow.tupled((_1.get, _2.get, _3.get, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column EmployeeId PrimaryKey */
    val employeeid: Column[Int] = column[Int]("EmployeeId", O.PrimaryKey)
    /** Database column LastName  */
    val lastname: Column[String] = column[String]("LastName")
    /** Database column FirstName  */
    val firstname: Column[String] = column[String]("FirstName")
    /** Database column Title  */
    val title: Column[Option[String]] = column[Option[String]]("Title")
    /** Database column ReportsTo  */
    val reportsto: Column[Option[Int]] = column[Option[Int]]("ReportsTo")
    /** Database column BirthDate  */
    val birthdate: Column[Option1] = column[Option1]("BirthDate")
    /** Database column HireDate  */
    val hiredate: Column[Option1] = column[Option1]("HireDate")
    /** Database column Address  */
    val address: Column[Option[String]] = column[Option[String]]("Address")
    /** Database column City  */
    val city: Column[Option[String]] = column[Option[String]]("City")
    /** Database column State  */
    val state: Column[Option[String]] = column[Option[String]]("State")
    /** Database column Country  */
    val country: Column[Option[String]] = column[Option[String]]("Country")
    /** Database column PostalCode  */
    val postalcode: Column[Option[String]] = column[Option[String]]("PostalCode")
    /** Database column Phone  */
    val phone: Column[Option[String]] = column[Option[String]]("Phone")
    /** Database column Fax  */
    val fax: Column[Option[String]] = column[Option[String]]("Fax")
    /** Database column Email  */
    val email: Column[Option[String]] = column[Option[String]]("Email")

    /** Foreign key referencing Employee (database name FK_EmployeeReportsTo) */
    lazy val employeeFk = foreignKey("FK_EmployeeReportsTo", reportsto, Employee)(r => r.employeeid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
  }
  /** Collection-like TableQuery object for table Employee */
  lazy val Employee = new TableQuery(tag => new Employee(tag))

  /** Entity class storing rows of table Genre
   *  @param genreid Database column GenreId PrimaryKey
   *  @param name Database column Name  */
  case class GenreRow(genreid: Int, name: Option[String])
  /** GetResult implicit for fetching GenreRow objects using plain SQL queries */
  implicit def GetResultGenreRow(implicit e0: GR[Int], e1: GR[Option[String]]): GR[GenreRow] = GR{
    prs => import prs._
    GenreRow.tupled((<<[Int], <<?[String]))
  }
  /** Table description of table Genre. Objects of this class serve as prototypes for rows in queries. */
  class Genre(tag: Tag) extends Table[GenreRow](tag, "Genre") {
    def * = (genreid, name) <> (GenreRow.tupled, GenreRow.unapply)
    /** Maps whole row to an option. Useful for outer joins. */
    def ? = (genreid.?, name).shaped.<>({r=>import r._; _1.map(_=> GenreRow.tupled((_1.get, _2)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column GenreId PrimaryKey */
    val genreid: Column[Int] = column[Int]("GenreId", O.PrimaryKey)
    /** Database column Name  */
    val name: Column[Option[String]] = column[Option[String]]("Name")
  }
  /** Collection-like TableQuery object for table Genre */
  lazy val Genre = new TableQuery(tag => new Genre(tag))

  /** Entity class storing rows of table Invoice
   *  @param invoiceid Database column InvoiceId PrimaryKey
   *  @param customerid Database column CustomerId 
   *  @param invoicedate Database column InvoiceDate 
   *  @param billingaddress Database column BillingAddress 
   *  @param billingcity Database column BillingCity 
   *  @param billingstate Database column BillingState 
   *  @param billingcountry Database column BillingCountry 
   *  @param billingpostalcode Database column BillingPostalCode 
   *  @param total Database column Total  */
  case class InvoiceRow(invoiceid: Int, customerid: Int, invoicedate: java.sql.Timestamp, billingaddress: Option[String], billingcity: Option[String], billingstate: Option[String], billingcountry: Option[String], billingpostalcode: Option[String], total: scala.math.BigDecimal)
  /** GetResult implicit for fetching InvoiceRow objects using plain SQL queries */
  implicit def GetResultInvoiceRow(implicit e0: GR[Int], e1: GR1, e2: GR[Option[String]], e3: GR1): GR[InvoiceRow] = GR{
    prs => import prs._
    InvoiceRow.tupled((<<[Int], <<[Int], <<1, <<?[String], <<?[String], <<?[String], <<?[String], <<?[String], <<1))
  }
  /** Table description of table Invoice. Objects of this class serve as prototypes for rows in queries. */
  class Invoice(tag: Tag) extends Table[InvoiceRow](tag, "Invoice") {
    def * = (invoiceid, customerid, invoicedate, billingaddress, billingcity, billingstate, billingcountry, billingpostalcode, total) <> (InvoiceRow.tupled, InvoiceRow.unapply)
    /** Maps whole row to an option. Useful for outer joins. */
    def ? = (invoiceid.?, customerid.?, invoicedate.?, billingaddress, billingcity, billingstate, billingcountry, billingpostalcode, total.?).shaped.<>({r=>import r._; _1.map(_=> InvoiceRow.tupled((_1.get, _2.get, _3.get, _4, _5, _6, _7, _8, _9.get)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column InvoiceId PrimaryKey */
    val invoiceid: Column[Int] = column[Int]("InvoiceId", O.PrimaryKey)
    /** Database column CustomerId  */
    val customerid: Column[Int] = column[Int]("CustomerId")
    /** Database column InvoiceDate  */
    val invoicedate: Column1 = column1("InvoiceDate")
    /** Database column BillingAddress  */
    val billingaddress: Column[Option[String]] = column[Option[String]]("BillingAddress")
    /** Database column BillingCity  */
    val billingcity: Column[Option[String]] = column[Option[String]]("BillingCity")
    /** Database column BillingState  */
    val billingstate: Column[Option[String]] = column[Option[String]]("BillingState")
    /** Database column BillingCountry  */
    val billingcountry: Column[Option[String]] = column[Option[String]]("BillingCountry")
    /** Database column BillingPostalCode  */
    val billingpostalcode: Column[Option[String]] = column[Option[String]]("BillingPostalCode")
    /** Database column Total  */
    val total: Column1 = column1("Total")

    /** Foreign key referencing Customer (database name FK_InvoiceCustomerId) */
    lazy val customerFk = foreignKey("FK_InvoiceCustomerId", customerid, Customer)(r => r.customerid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
  }
  /** Collection-like TableQuery object for table Invoice */
  lazy val Invoice = new TableQuery(tag => new Invoice(tag))

  /** Entity class storing rows of table Invoiceline
   *  @param invoicelineid Database column InvoiceLineId PrimaryKey
   *  @param invoiceid Database column InvoiceId 
   *  @param trackid Database column TrackId 
   *  @param unitprice Database column UnitPrice 
   *  @param quantity Database column Quantity  */
  case class InvoicelineRow(invoicelineid: Int, invoiceid: Int, trackid: Int, unitprice: scala.math.BigDecimal, quantity: Int)
  /** GetResult implicit for fetching InvoicelineRow objects using plain SQL queries */
  implicit def GetResultInvoicelineRow(implicit e0: GR[Int], e1: GR1): GR[InvoicelineRow] = GR{
    prs => import prs._
    InvoicelineRow.tupled((<<[Int], <<[Int], <<[Int], <<1, <<[Int]))
  }
  /** Table description of table InvoiceLine. Objects of this class serve as prototypes for rows in queries. */
  class Invoiceline(tag: Tag) extends Table[InvoicelineRow](tag, "InvoiceLine") {
    def * = (invoicelineid, invoiceid, trackid, unitprice, quantity) <> (InvoicelineRow.tupled, InvoicelineRow.unapply)
    /** Maps whole row to an option. Useful for outer joins. */
    def ? = (invoicelineid.?, invoiceid.?, trackid.?, unitprice.?, quantity.?).shaped.<>({r=>import r._; _1.map(_=> InvoicelineRow.tupled((_1.get, _2.get, _3.get, _4.get, _5.get)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column InvoiceLineId PrimaryKey */
    val invoicelineid: Column[Int] = column[Int]("InvoiceLineId", O.PrimaryKey)
    /** Database column InvoiceId  */
    val invoiceid: Column[Int] = column[Int]("InvoiceId")
    /** Database column TrackId  */
    val trackid: Column[Int] = column[Int]("TrackId")
    /** Database column UnitPrice  */
    val unitprice: Column1 = column1("UnitPrice")
    /** Database column Quantity  */
    val quantity: Column[Int] = column[Int]("Quantity")

    /** Foreign key referencing Invoice (database name FK_InvoiceLineInvoiceId) */
    lazy val invoiceFk = foreignKey("FK_InvoiceLineInvoiceId", invoiceid, Invoice)(r => r.invoiceid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
    /** Foreign key referencing Track (database name FK_InvoiceLineTrackId) */
    lazy val trackFk = foreignKey("FK_InvoiceLineTrackId", trackid, Track)(r => r.trackid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
  }
  /** Collection-like TableQuery object for table Invoiceline */
  lazy val Invoiceline = new TableQuery(tag => new Invoiceline(tag))

  /** Entity class storing rows of table Mediatype
   *  @param mediatypeid Database column MediaTypeId PrimaryKey
   *  @param name Database column Name  */
  case class MediatypeRow(mediatypeid: Int, name: Option[String])
  /** GetResult implicit for fetching MediatypeRow objects using plain SQL queries */
  implicit def GetResultMediatypeRow(implicit e0: GR[Int], e1: GR[Option[String]]): GR[MediatypeRow] = GR{
    prs => import prs._
    MediatypeRow.tupled((<<[Int], <<?[String]))
  }
  /** Table description of table MediaType. Objects of this class serve as prototypes for rows in queries. */
  class Mediatype(tag: Tag) extends Table[MediatypeRow](tag, "MediaType") {
    def * = (mediatypeid, name) <> (MediatypeRow.tupled, MediatypeRow.unapply)
    /** Maps whole row to an option. Useful for outer joins. */
    def ? = (mediatypeid.?, name).shaped.<>({r=>import r._; _1.map(_=> MediatypeRow.tupled((_1.get, _2)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column MediaTypeId PrimaryKey */
    val mediatypeid: Column[Int] = column[Int]("MediaTypeId", O.PrimaryKey)
    /** Database column Name  */
    val name: Column[Option[String]] = column[Option[String]]("Name")
  }
  /** Collection-like TableQuery object for table Mediatype */
  lazy val Mediatype = new TableQuery(tag => new Mediatype(tag))

  /** Entity class storing rows of table Playlist
   *  @param playlistid Database column PlaylistId PrimaryKey
   *  @param name Database column Name  */
  case class PlaylistRow(playlistid: Int, name: Option[String])
  /** GetResult implicit for fetching PlaylistRow objects using plain SQL queries */
  implicit def GetResultPlaylistRow(implicit e0: GR[Int], e1: GR[Option[String]]): GR[PlaylistRow] = GR{
    prs => import prs._
    PlaylistRow.tupled((<<[Int], <<?[String]))
  }
  /** Table description of table Playlist. Objects of this class serve as prototypes for rows in queries. */
  class Playlist(tag: Tag) extends Table[PlaylistRow](tag, "Playlist") {
    def * = (playlistid, name) <> (PlaylistRow.tupled, PlaylistRow.unapply)
    /** Maps whole row to an option. Useful for outer joins. */
    def ? = (playlistid.?, name).shaped.<>({r=>import r._; _1.map(_=> PlaylistRow.tupled((_1.get, _2)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column PlaylistId PrimaryKey */
    val playlistid: Column[Int] = column[Int]("PlaylistId", O.PrimaryKey)
    /** Database column Name  */
    val name: Column[Option[String]] = column[Option[String]]("Name")
  }
  /** Collection-like TableQuery object for table Playlist */
  lazy val Playlist = new TableQuery(tag => new Playlist(tag))

  /** Entity class storing rows of table Playlisttrack
   *  @param playlistid Database column PlaylistId 
   *  @param trackid Database column TrackId  */
  case class PlaylisttrackRow(playlistid: Int, trackid: Int)
  /** GetResult implicit for fetching PlaylisttrackRow objects using plain SQL queries */
  implicit def GetResultPlaylisttrackRow(implicit e0: GR[Int]): GR[PlaylisttrackRow] = GR{
    prs => import prs._
    PlaylisttrackRow.tupled((<<[Int], <<[Int]))
  }
  /** Table description of table PlaylistTrack. Objects of this class serve as prototypes for rows in queries. */
  class Playlisttrack(tag: Tag) extends Table[PlaylisttrackRow](tag, "PlaylistTrack") {
    def * = (playlistid, trackid) <> (PlaylisttrackRow.tupled, PlaylisttrackRow.unapply)
    /** Maps whole row to an option. Useful for outer joins. */
    def ? = (playlistid.?, trackid.?).shaped.<>({r=>import r._; _1.map(_=> PlaylisttrackRow.tupled((_1.get, _2.get)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column PlaylistId  */
    val playlistid: Column[Int] = column[Int]("PlaylistId")
    /** Database column TrackId  */
    val trackid: Column[Int] = column[Int]("TrackId")

    /** Primary key of Playlisttrack (database name PlaylistTrack_PK) */
    val pk = primaryKey("PlaylistTrack_PK", (playlistid, trackid))

    /** Foreign key referencing Playlist (database name FK_PlaylistTrackPlaylistId) */
    lazy val playlistFk = foreignKey("FK_PlaylistTrackPlaylistId", playlistid, Playlist)(r => r.playlistid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
    /** Foreign key referencing Track (database name FK_PlaylistTrackTrackId) */
    lazy val trackFk = foreignKey("FK_PlaylistTrackTrackId", trackid, Track)(r => r.trackid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
  }
  /** Collection-like TableQuery object for table Playlisttrack */
  lazy val Playlisttrack = new TableQuery(tag => new Playlisttrack(tag))

  /** Entity class storing rows of table Track
   *  @param trackid Database column TrackId PrimaryKey
   *  @param name Database column Name 
   *  @param albumid Database column AlbumId 
   *  @param mediatypeid Database column MediaTypeId 
   *  @param genreid Database column GenreId 
   *  @param composer Database column Composer 
   *  @param milliseconds Database column Milliseconds 
   *  @param bytes Database column Bytes 
   *  @param unitprice Database column UnitPrice  */
  case class TrackRow(trackid: Int, name: String, albumid: Option[Int], mediatypeid: Int, genreid: Option[Int], composer: Option[String], milliseconds: Int, bytes: Option[Int], unitprice: scala.math.BigDecimal)
  /** GetResult implicit for fetching TrackRow objects using plain SQL queries */
  implicit def GetResultTrackRow(implicit e0: GR[Int], e1: GR[String], e2: GR[Option[Int]], e3: GR[Option[String]], e4: GR1): GR[TrackRow] = GR{
    prs => import prs._
    TrackRow.tupled((<<[Int], <<[String], <<?[Int], <<[Int], <<?[Int], <<?[String], <<[Int], <<?[Int], <<1))
  }
  /** Table description of table Track. Objects of this class serve as prototypes for rows in queries. */
  class Track(tag: Tag) extends Table[TrackRow](tag, "Track") {
    def * = (trackid, name, albumid, mediatypeid, genreid, composer, milliseconds, bytes, unitprice) <> (TrackRow.tupled, TrackRow.unapply)
    /** Maps whole row to an option. Useful for outer joins. */
    def ? = (trackid.?, name.?, albumid, mediatypeid.?, genreid, composer, milliseconds.?, bytes, unitprice.?).shaped.<>({r=>import r._; _1.map(_=> TrackRow.tupled((_1.get, _2.get, _3, _4.get, _5, _6, _7.get, _8, _9.get)))}, (_:Any) =>  throw new Exception("Inserting into ? projection not supported."))

    /** Database column TrackId PrimaryKey */
    val trackid: Column[Int] = column[Int]("TrackId", O.PrimaryKey)
    /** Database column Name  */
    val name: Column[String] = column[String]("Name")
    /** Database column AlbumId  */
    val albumid: Column[Option[Int]] = column[Option[Int]]("AlbumId")
    /** Database column MediaTypeId  */
    val mediatypeid: Column[Int] = column[Int]("MediaTypeId")
    /** Database column GenreId  */
    val genreid: Column[Option[Int]] = column[Option[Int]]("GenreId")
    /** Database column Composer  */
    val composer: Column[Option[String]] = column[Option[String]]("Composer")
    /** Database column Milliseconds  */
    val milliseconds: Column[Int] = column[Int]("Milliseconds")
    /** Database column Bytes  */
    val bytes: Column[Option[Int]] = column[Option[Int]]("Bytes")
    /** Database column UnitPrice  */
    val unitprice: Column1 = column1("UnitPrice")

    /** Foreign key referencing Album (database name FK_TrackAlbumId) */
    lazy val albumFk = foreignKey("FK_TrackAlbumId", albumid, Album)(r => r.albumid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
    /** Foreign key referencing Genre (database name FK_TrackGenreId) */
    lazy val genreFk = foreignKey("FK_TrackGenreId", genreid, Genre)(r => r.genreid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
    /** Foreign key referencing Mediatype (database name FK_TrackMediaTypeId) */
    lazy val mediatypeFk = foreignKey("FK_TrackMediaTypeId", mediatypeid, Mediatype)(r => r.mediatypeid, onUpdate=ForeignKeyAction.NoAction, onDelete=ForeignKeyAction.NoAction)
    }
    /** Collection-like TableQuery object for table Track */
    lazy val Track = new TableQuery(tag => new Track(tag))
}