<commit_before>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# MIT License

import time
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
from sqlalchemy.pool import NullPool
from anormbookmarker.BaseMixin import BASE

def create_database(config):
    '''Create new database.'''
    print("create_database() config.dbname:", config.dbname)
    print("create_database() config.dbpath:", config.dbpath)
    with create_engine(config.pg_dbpath, isolation_level='AUTOCOMMIT', echo=False).connect() as connection:
        connection.execute('CREATE DATABASE ' + config.dbname)

def get_engine(config):
    assert isinstance(config.dbpath, str)
    engine = create_engine(config.dbpath, echo=False)
    return engine

def create_tables(config, schema=BASE):
    '''Create tables.'''
    engine = get_engine(config=config)
    schema.metadata.create_all(engine)

def create_database_and_tables(config):
    '''Create new database and tables.'''
    create_database(config=config)
    create_tables(config, schema=BASE)

def create_session(config):<commit_msg>auto-commit<commit_after>#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# MIT License

import time
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
from sqlalchemy.pool import NullPool
from anormbookmarker.BaseMixin import BASE

def create_database(config):
    '''Create new database.'''
    print("create_database() config.dbname:", config.dbname)
    print("create_database() config.dbpath:", config.dbpath)
    #with create_engine(config.pg_dbpath, isolation_level='AUTOCOMMIT', echo=False).connect() as connection:
    with create_engine(config.dbpath, isolation_level='AUTOCOMMIT', echo=False).connect() as connection:
        connection.execute('CREATE DATABASE ' + config.dbname)

def get_engine(config):
    assert isinstance(config.dbpath, str)
    engine = create_engine(config.dbpath, echo=False)
    return engine

def create_tables(config, schema=BASE):
    '''Create tables.'''
    engine = get_engine(config=config)
    schema.metadata.create_all(engine)

def create_database_and_tables(config):
    '''Create new database and tables.'''
    create_database(config=config)
    create_tables(config, schema=BASE)

def create_session(config):
{'fraction_non_alphanumeric': 0.11286201022146508, 'fraction_numerical': 0.0017035775127768314, 'mean_word_length': 5.348648648648648, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1762109', 'n_tokens_mistral': 703, 'n_tokens_neox': 693, 'n_words': 161}