forked from scalikejdbc/csvquery
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sbt
More file actions
83 lines (76 loc) · 2.53 KB
/
Copy pathbuild.sbt
File metadata and controls
83 lines (76 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
lazy val root = (project in file("."))
.settings(
organization := "org.scalikejdbc",
name := "csvquery",
version := "1.5.1-SNAPSHOT",
scalaVersion := "2.13.18",
crossScalaVersions := Seq("2.12.21", "2.13.18", "3.3.8"),
libraryDependencies ++= Seq(
"com.h2database" % "h2" % "2.2.224",
"org.scalikejdbc" %% "scalikejdbc" % "4.3.5",
"ch.qos.logback" % "logback-classic" % "1.6.1" % "provided",
"org.scalatest" %% "scalatest-funspec" % "3.2.20" % "test",
"org.scalatest" %% "scalatest-shouldmatchers" % "3.2.20" % "test"
),
Test / parallelExecution := false,
Test / logBuffered := false,
scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-feature",
"-release:8"
),
initialCommands := """
import scalikejdbc._
import csvquery._
Class.forName("org.h2.Driver")
implicit val session: DBSession = autoCSVSession
val csv = CSV("./sample.csv", Seq("name", "age"))
val count = withCSV(csv) { table =>
sql"select count(*) from $table".map(_.long(1)).single.apply().get
}
val records = withCSV(csv) { table =>
sql"select * from $table".toMap.list.apply()
}
case class Account(name: String, companyName: String, company: Option[Company])
case class Company(name: String, url: String)
val (accountsCsv, companiesCsv) = (
CSV("src/test/resources/accounts.csv", Seq("name", "company_name")),
CSV("src/test/resources/companies.csv", Seq("name", "url"))
)
val accounts: Seq[Account] = withCSV(accountsCsv, companiesCsv) { (a, c) =>
sql"select a.name, a.company_name, c.url from $a a left join $c c on a.company_name = c.name".map { rs =>
new Account(
name = rs.get("name"),
companyName = rs.get("company_name"),
company = rs.stringOpt("url").map(url => Company(rs.get("company_name"), url))
)
}.list.apply()
}
""",
publishTo := {
if (isSnapshot.value) { None }
else { localStaging.value }
},
publishMavenStyle := true,
pomIncludeRepository := { x => false },
pomExtra := <url>https://github.com/scalikejdbc/csvquery/</url>
<licenses>
<license>
<name>MIT License</name>
<url>https://www.opensource.org/licenses/mit-license</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:scalikejdbc/csvquery.git</url>
<connection>scm:git:git@github.com:scalikejdbc/csvquery.git</connection>
</scm>
<developers>
<developer>
<id>seratch</id>
<name>Kazuhiro Sera</name>
<url>https://git.io/sera</url>
</developer>
</developers>
)