Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gmazzo/gradle-sqlite-plugin
A Gradle plugin to allow manipulating SQLite databases in the buildScript
https://github.com/gmazzo/gradle-sqlite-plugin
gradle gradle-plugin sqlite sqlite-database
Last synced: 27 days ago
JSON representation
A Gradle plugin to allow manipulating SQLite databases in the buildScript
- Host: GitHub
- URL: https://github.com/gmazzo/gradle-sqlite-plugin
- Owner: gmazzo
- Created: 2017-09-12T13:58:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-20T18:34:53.000Z (almost 7 years ago)
- Last Synced: 2024-11-15T04:42:04.701Z (3 months ago)
- Topics: gradle, gradle-plugin, sqlite, sqlite-database
- Language: Groovy
- Homepage: https://plugins.gradle.org/plugin/com.github.gmazzo.sqlite
- Size: 56.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gradle-sqlite-plugin
A Gradle plugin to allow manipulating SQLite databases in the buildScript
> Credits to [tim-yates](https://stackoverflow.com/users/6509/tim-yates) for the working code
https://stackoverflow.com/a/33904851/1007772## Usage
On your `build.gradle` add:
```groovy
plugins {
id 'com.github.gmazzo.sqlite'
}
```
Visit [Gradle plugins](https://plugins.gradle.org/plugin/com.github.gmazzo.sqlite) for further details on how to apply itAfter applying, the standard `groovy.sql.Sql` can be used to open or create any SQLite database with:
```groovy
import groovy.sql.SqlSql.newInstance('jdbc:sqlite:' + databaseFile, 'org.sqlite.JDBC')
```
Or you can use this shortcut function:
```groovy
openSQLiteDatabase(databaseFile)
```### Example
```groovy
plugins {
id 'com.github.gmazzo.sqlite'
}task createSampleDatabase {
def databaseFile = file("$buildDir/sample.db")outputs.file databaseFile
doLast {
def db = openSQLiteDatabase(databaseFile)
db.execute 'CREATE TABLE sample (name TEXT NOT NULL, value INTEGER NOT NULL)'
db.execute 'INSERT INTO sample VALUES (\'AAA\', 0)'
db.execute 'INSERT INTO sample VALUES (\'BBB\', 1)'
}
}
```## Configuration
By default, this plugins relies in the `org.xerial:sqlite-jdbc:3.20.0` SQLite driver.
If you want to change it or update its version, add:
```groovy
sqlite {
driverDependency 'org.xerial:sqlite-jdbc:'
}
```