<commit_before># Active-JDBC

Wrap up Java SQLite databases like it's ActiveRecord.

Kind of like [my other one](https://github.com/JavaNut13/Android-DB-Interface), but a bit smarter and for JDBC, rather than the built-in Android one.

## How to:

Clone the repo, chuck the _dbinterface_ folder into your project (`Record`, `DBInterface`, `HashRecord` and `Query` are required). Create a class for each table in your database, that extends `Record`. The name of the table should eb the same as the class name.

In the DBInterface `upgrade()` method, run SQL to create your tables and other initialisation - depending on the existing version of the database.

### Open the Database

Open the database - either in memory or in a `.db` file:

    DBInterface dbi = DBInterface().open(); // open in memory
    // OR
    DBInterface dbi = DBInterface(new File("/Users/me/data.db"));

If you always want to use this database and never have to reference it, make it global:

    dbi.globalize();

This means that updates and lookups do not have to be passed a database reference. When you're done with the database, close it:

    dbi.close();

### Creating records

Create a Location (Assuming `Location` is a subclass of `Record`):
<commit_msg>#hashtag titles<commit_after># Active-JDBC

Wrap up Java SQLite databases like it's ActiveRecord.

Kind of like [my other one](https://github.com/JavaNut13/Android-DB-Interface), but a bit smarter and for JDBC, rather than the built-in Android one.

## How to:

Clone the repo, chuck the _dbinterface_ folder into your project (`Record`, `DBInterface`, `HashRecord` and `Query` are required). Create a class for each table in your database, that extends `Record`. The name of the table should eb the same as the class name.

In the DBInterface `upgrade()` method, run SQL to create your tables and other initialisation - depending on the existing version of the database.

## Open the Database

Open the database - either in memory or in a `.db` file:

    DBInterface dbi = DBInterface().open(); // open in memory
    // OR
    DBInterface dbi = DBInterface(new File("/Users/me/data.db"));

If you always want to use this database and never have to reference it, make it global:

    dbi.globalize();

This means that updates and lookups do not have to be passed a database reference. When you're done with the database, close it:

    dbi.close();

## Creating records

Create a Location (Assuming `Location` is a subclass of `Record`):

{'fraction_non_alphanumeric': 0.08595641646489104, 'fraction_numerical': 0.0016142050040355124, 'mean_word_length': 3.997983870967742, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1132199', 'n_tokens_mistral': 691, 'n_tokens_neox': 660, 'n_words': 349}