<commit_before>import java.sql.SQLException;
import groovy.sql.Sql;

String from = '''
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:testFromH2
jdbc.username=scott
jdbc.password=<PASSWORD>
''';

String to = '''
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:testToH2
jdbc.username=scott
jdbc.password=<PASSWORD>
''';

File fromFile = File.createTempFile("from....", ".properties");
fromFile.setText(from);
File toFile = File.createTempFile("to.....", ".properties");
toFile.setText(to);

Properties fromProperties = new Properties();
fromProperties.load(new StringReader(from));
Properties toProperties = new Properties();
toProperties.load(new StringReader(to));

def createNewSql = { Properties p ->
  return Sql.newInstance(p.'jdbc.url', p.'jdbc.username', p.'jdbc.password', p.'jdbc.driver');
}

def count = { Sql sql, String tableName ->
  def result = sql.rows("select count(1) c from ${tableName};" as String);
  return result[0][0];
}

def createTableDealers = { Sql sql ->
  sql.execute('''
    create table DEALERS (
      id integer not null primary key,
      name varchar(200),
      city varchar(200)
    )<commit_msg>Some working tests<commit_after>import java.sql.SQLException;
import groovy.sql.Sql;

String from = '''
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:testFromH2
jdbc.username=scott
jdbc.password=<PASSWORD>
''';

String to = '''
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:testToH2
jdbc.username=scott
jdbc.password=<PASSWORD>
''';

File fromFile = File.createTempFile("from....", ".properties");
fromFile.setText(from);
File toFile = File.createTempFile("to.....", ".properties");
toFile.setText(to);

Properties fromProperties = new Properties();
fromProperties.load(new StringReader(from));
Properties toProperties = new Properties();
toProperties.load(new StringReader(to));

def createNewSql = { Properties p ->
  return Sql.newInstance(p.'jdbc.url', p.'jdbc.username', p.'jdbc.password', p.'jdbc.driver');
}

def count = { Sql sql, String tableName ->
  def result = sql.rows("select count(1) c from ${tableName};" as String); // yes, you could do a SQL injection here...
  return result[0][0];
}

def createTableDealers = { Sql sql ->
  sql.execute('''
    create table DEALERS (
      id integer not null primary key,
      name varchar(200),
      city varchar(200)
    )
{'fraction_non_alphanumeric': 0.16, 'fraction_numerical': 0.013043478260869565, 'mean_word_length': 4.709677419354839, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3508726', 'n_tokens_mistral': 784, 'n_tokens_neox': 738, 'n_words': 174}