WordPress .htaccess rewrite for custom template

Don’t use an .htaccess rule, use WordPress internal rewrite system.

First, add a query var for your ID:

function wpd_query_vars( $query_vars ){
    $query_vars[] = 'my_id';
    return $query_vars;
}
add_filter('query_vars', 'wpd_query_vars');

Then add an internal rule to catch incoming requests, load your database page, and set the ID query var:

function wpd_database_rewrites(){
    add_rewrite_rule(
        'database/([0-9]+)/?([a-zA-Z0-9_-]*)/?([a-zA-Z0-9_-]*).html$',
        'index.php?pagename=database&my_id=$matches[1]',
        'top'
    );
}
add_action( 'init', 'wpd_database_rewrites' );

Then you can access the value of the ID via get_qury_var( 'my_id' );

Add a couple more query vars and set those via $matches[2] and $matches[3] if you also want category and title.