<commit_before># Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This package handles setting up and providing the database connection."""

from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import as_declarative
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy import Column, Integer
from sqlalchemy import DateTime
from sqlalchemy import func
from flask import abort
from flask_login import current_user
from flask_sqlalchemy import BaseQuery

# The database session
engine = None
session_maker = sessionmaker()
db_session = scoped_session(session_maker)


def configure_engine(url):
    """Configure and setup the database session."""
    # These needs to be global because of the way Flask works.
    # pylint: disable=global-variable-not-assigned
    global engine, session_maker, db_session
    engine = create_engine(url)
    db_session.remove()
    # Set the query class to our own AclBaseQuery
    session_maker.configure(
        autocommit=False, autoflush=False, bind=engine, query_cls=AclBaseQuery)


def init_db():
    """Initialize the database based on the implemented models. This will setup
    the database on the first run.<commit_msg>Style fix<commit_after># Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This package handles setting up and providing the database connection."""

from flask import abort
from flask_login import current_user
from flask_sqlalchemy import BaseQuery
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import as_declarative
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy import Column, Integer
from sqlalchemy import DateTime
from sqlalchemy import func


# The database session
engine = None
session_maker = sessionmaker()
db_session = scoped_session(session_maker)


def configure_engine(url):
    """Configure and setup the database session."""
    # These needs to be global because of the way Flask works.
    # pylint: disable=global-variable-not-assigned
    global engine, session_maker, db_session
    engine = create_engine(url)
    db_session.remove()
    # Set the query class to our own AclBaseQuery
    session_maker.configure(
        autocommit=False, autoflush=False, bind=engine, query_cls=AclBaseQuery)


def init_db():
    """Initialize the database based on the implemented models. This will setup
    the database on the first run.
{'fraction_non_alphanumeric': 0.060673531867520177, 'fraction_numerical': 0.004453103256331756, 'mean_word_length': 4.713831478537361, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4368344', 'n_tokens_mistral': 962, 'n_tokens_neox': 922, 'n_words': 414}