29 lines
695 B
Dart
29 lines
695 B
Dart
import 'dart:io';
|
|
|
|
import 'package:jadb/_data_ingestion/open_local_db.dart';
|
|
import 'package:jadb/search.dart';
|
|
|
|
Future<JaDBConnection> setup_database_connection() async {
|
|
final lib_sqlite_path = Platform.environment['LIBSQLITE_PATH'];
|
|
final jadb_path = Platform.environment['JADB_PATH'];
|
|
|
|
if (lib_sqlite_path == null) {
|
|
throw Exception("LIBSQLITE_PATH is not set");
|
|
}
|
|
|
|
if (jadb_path == null) {
|
|
throw Exception("JADB_PATH is not set");
|
|
}
|
|
|
|
final db_connection = await openLocalDb(
|
|
libsqlitePath: lib_sqlite_path,
|
|
jadbPath: jadb_path,
|
|
);
|
|
|
|
if (db_connection == null) {
|
|
throw Exception("Failed to open database");
|
|
}
|
|
|
|
return JaDBConnection(db_connection);
|
|
}
|