File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33[ ![ Build Status] ( https://travis-ci.org/ocadaruma/scalikejdbc-bigquery.svg?branch=master )] ( https://travis-ci.org/ocadaruma/scalikejdbc-bigquery )
44
55ScalikeJDBC extension for Google BigQuery
6+
7+ ## Prerequisites
8+
9+ - Java 8
10+ - Scala 2.11.x
11+ - ScalikeJDBC 2.4.x or newer
12+
13+ ## Installation
14+
15+ ``` scala
16+ libraryDependencies ++= Seq (
17+ " com.mayreh" %% " scalikejdbc-bigquery" % " 0.0.1" ,
18+ " org.scalikejdbc" %% " scalikejdbc" % scalikejdbcVersion // specify scalikejdbc version you want.
19+ )
20+ ```
21+
22+ ## Usage
23+
24+ ``` scala
25+ import com .google .auth .oauth2 .GoogleCredentials
26+ import com .google .cloud .bigquery .{BigQueryOptions , DatasetId }
27+
28+ // instantiate BigQuery service and DatsetId
29+ val credentials = GoogleCredentials .fromStream(new FileInputStream (" /path/to/key.json" ))
30+ val bigQuery = BigQueryOptions .newBuilder()
31+ .setCredentials(credentials)
32+ .setProjectId(" your-gcp-project-id" )
33+ .build()
34+ .getService
35+
36+ val datasetId = DatasetId .of(" your-gcp-project-id" , " your-dataset" )
37+
38+ // build query by QueryDSL then execute
39+ val executor = new QueryExecutor (bigQuery, QueryConfig ())
40+
41+ val response = bq {
42+ selectFrom(User in dataset as u )
43+ .where.eq(u.id, 42 )
44+ }.map(User (_)).single.run(executor)
45+
46+ response.result // => Option[User]
47+ ```
48+
49+ See also [ integration test] ( https://github.com/ocadaruma/scalikejdbc-bigquery/blob/master/src/it/scala/scalikejdbc/bigquery/QueryDSLIntegration.scala ) .
50+
51+ ## Current status
52+
53+ This project is still in an early stage. Newer releases can include breaking changes.
54+
55+ Be careful using in production.
Original file line number Diff line number Diff line change 11name := " scalikejdbc-bigquery"
22
3+ organization := " com.mayreh"
4+
5+ licenses += ((" Apache-2.0" , url(" https://raw.githubusercontent.com/ocadaruma/scalikejdbc-bigquery/master/LICENSE" )))
6+
37version := " 0.0.1-SNAPSHOT"
48
9+ publishMavenStyle := true
10+
511scalaVersion := " 2.11.8"
612
13+ scalacOptions ++= Seq (" -unchecked" , " -deprecation" , " -feature" )
14+
715configs(IntegrationTest )
816
917inConfig(IntegrationTest )(Defaults .itSettings)
Original file line number Diff line number Diff line change 1+ addSbtPlugin(" org.xerial.sbt" % " sbt-sonatype" % " 1.1" )
2+
3+ addSbtPlugin(" com.jsuereth" % " sbt-pgp" % " 1.0.1" )
Original file line number Diff line number Diff line change 1+ sonatypeProfileName := " com.mayreh"
2+
3+ pomExtra in Global := {
4+ <url >https:// github.com/ ocadaruma/ scalikejdbc- bigquery</url >
5+ <scm >
6+ <connection >" scm:git:git@github.com:ocadaruma/scalikejdbc-bigquery.git" </connection >
7+ <url >git@ github.com: ocadaruma/ scalikejdbc- bigquery.git</url >
8+ </scm >
9+ <developers >
10+ <developer >
11+ <id >ocadaruma</id >
12+ <name >Haruki Okada </name >
13+ </developer >
14+ </developers >
15+ }
You can’t perform that action at this time.
0 commit comments