<commit_before>require "active_record"

ActiveRecord::Base.establish_connection(
  :adapter => "sqlite3",
  :database => "file::memory:?cache=shared"
)

ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define(:version => 1) do
  create_table :users do |t|
    t.string :name
  end
end

LOG = []

ActiveRecord::ConnectionAdapters::SQLite3Adapter.class_eval do
  alias_method :exec_query_without_log, :exec_query
  def exec_query(query, *args, &block)
    LOG << query
    exec_query_without_log(query, *args, &block)
  end

  alias_method :execute_without_log, :execute
  def execute(query, *args, &block)
    LOG << query
    execute_without_log(query, *args, &block)
  end
end<commit_msg>Clean up the sqlite file after test run<commit_after>require "active_record"

sqlite_file = "file::memory:?cache=shared"
FileUtils.rm_f(sqlite_file)

ActiveRecord::Base.establish_connection(
  :adapter => "sqlite3",
  :database => sqlite_file
)

RSpec.configure do |c|
  c.after(:suite) do
    FileUtils.rm_f(sqlite_file)
  end
end

ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define(:version => 1) do
  create_table :users do |t|
    t.string :name
  end
end

LOG = []

ActiveRecord::ConnectionAdapters::SQLite3Adapter.class_eval do
  alias_method :exec_query_without_log, :exec_query
  def exec_query(query, *args, &block)
    LOG << query
    exec_query_without_log(query, *args, &block)
  end

  alias_method :execute_without_log, :execute
  def execute(query, *args, &block)
    LOG << query
    execute_without_log(query, *args, &block)
  end
end
{'fraction_non_alphanumeric': 0.11764705882352941, 'fraction_numerical': 0.0038363171355498722, 'mean_word_length': 5.26, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '5068798', 'n_tokens_mistral': 545, 'n_tokens_neox': 534, 'n_words': 117}