Created
November 20, 2019 19:55
-
-
Save kousen/5cbc63501174e77f912eeba7dedc9b20 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@GrabConfig(systemClassLoader=true) | |
@Grab('com.h2database:h2:1.4.200') | |
Sql sql = Sql.newInstance(url: 'jdbc:h2:~/astro', driver: 'org.h2.Driver') | |
sql.execute ''' | |
create table if not exists ASTRONAUTS( | |
id int auto_increment primary key, | |
name varchar(50), | |
craft varchar(50) | |
) | |
''' | |
response.people.each { | |
sql.execute "insert into ASTRONAUTS(name, craft) values ($it.name, $it.craft)" | |
} | |
sql.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Saving the astronauts in a database