<commit_before>import 'package:http/http.dart' as http;
import 'package:sqlite3/wasm.dart';

Future<void> main() async {
  final fileSystem = await IndexedDbFileSystem.open(dbName: 'test');
  final response = await http.get(Uri.parse('sqlite3.wasm'));
  final sqlite3 = await WasmSqlite3.load(
      response.bodyBytes, SqliteEnvironment(fileSystem: fileSystem));
  final database = sqlite3.open('test');
  print('${database.userVersion} (should be 0)');
  database.userVersion = 1;
  print('${database.userVersion} (should be 1)');

  database.execute('CREATE TABLE IF NOT EXISTS users ( '
      'id INTEGER NOT NULL, '
      'name TEXT NOT NULL, email TEXT NOT NULL UNIQUE, '
      'password TEXT NOT NULL, '
      'user_id INTEGER NOT NULL, '
      'currentCompanyId INTEGER NULL REFERENCES companies (id), '
      'PRIMARY KEY (id));');

  final prepared = database.prepare('INSERT INTO users '
      '(id, name, email, password, user_id) VALUES (?, ?, ?, ?, ?)');

  for (var i = 0; i < 200; i++) {
    prepared.execute(
      [
        BigInt.from(i),
        'name',
        'email${BigInt.from(i)}',
        'password',
        BigInt.from(i),
      ],
    );
  }

  database.select('SELECT * FROM users').forEach((element) {
    print(element.values);
  });

  database.dispose();
  //await fileSystem.close();
  await Future<void>.delayed(const Duration(milliseconds: 5000));

  final fileSystem2 = await IndexedDbFileSystem.open(dbName: 'test');
  final sqlite32 = await WasmSqlite3.load(
      response.bodyBytes, SqliteEnvironment(fileSystem: fileSystem2));
  final database2 = sqlite32.open('test');
  print('${database2.userVersion} (should be 2)');

  database2.select('SELECT * FROM users').forEach((element) {
    print(element.values);
  });
}
<commit_msg>Rollback changes to example<commit_after>import 'package:http/http.dart' as http;
import 'package:sqlite3/wasm.dart';

Future<void> main() async {
  final fs = await IndexedDbFileSystem.open(dbName: 'test');
  print('loaded fs');

  final response = await http.get(Uri.parse('sqlite3.wasm'));
  final sqlite = await WasmSqlite3.load(
      response.bodyBytes, SqliteEnvironment(fileSystem: fs));

  print('Version of sqlite used is ${sqlite.version}');

  print('opening a persistent database');
  var db = sqlite.open('test.db');

  if (db.userVersion == 0) {
    db
      ..execute('CREATE TABLE foo (x TEXT);')
      ..execute("INSERT INTO foo VALUES ('foo'), ('bar');")
      ..userVersion = 1;
  }

  print(db.select('SELECT * FROM foo'));
  await fs.flush();

  print('re-opening database');
  db = sqlite.open('test.db');
  print(db.select('SELECT * FROM foo'));
}

{'fraction_non_alphanumeric': 0.15829240649792217, 'fraction_numerical': 0.012089157536834151, 'mean_word_length': 3.779783393501805, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, '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': '494221', 'n_tokens_mistral': 887, 'n_tokens_neox': 836, 'n_words': 204}