@GrabConfig(systemClassLoader = true)
@Grab('mysql:mysql-connector-java:5.1.31')
import groovy.sql.Sql
def db = Sql.newInstance("jdbc:mysql://localhost:3306/dbname", "root", "", "com.mysql.jdbc.Driver")
db.eachRow('show tables') { row ->
def tableName = row[0]
db.eachRow("select count(*) as cnt from " + tableName) {
println "$tableName: $it.cnt"
}
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme