<commit_before>
"""Maintain a connection to a SQL database.

This class translates between raco's internal data types and sqlalchemy's
representation.
"""

import collections

from sqlalchemy import (Column, Table, MetaData, Integer, String, DateTime,
                        Float, Boolean, create_engine, select, func)

from raco.scheme import Scheme
import raco.types as types

type_to_raco = {Integer: types.LONG_TYPE,
                String: types.STRING_TYPE,
                Float: types.FLOAT_TYPE}


raco_to_type = {types.LONG_TYPE: Integer,
                types.INT_TYPE: Integer,
                types.STRING_TYPE: String,
                types.FLOAT_TYPE: Float,
                types.DOUBLE_TYPE: Float,
                types.BOOLEAN_TYPE: Boolean,
                types.DATETIME_TYPE: DateTime}


class DBConnection(object):

    def __init__(self, connection_string='sqlite:///:memory:', echo=False):
        """Initialize a SQLLite connection."""
        self.engine = create_engine(connection_string, echo=echo)
        self.metadata = MetaData()
        self.metadata.bind = self.engine<commit_msg>Add more type conversions to dbconn.py<commit_after>
"""Maintain a connection to a SQL database.

This class translates between raco's internal data types and sqlalchemy's
representation.
"""

import collections

from sqlalchemy import (Column, Table, MetaData, Integer, String, DateTime,
                        Float, Boolean, create_engine, select, func)

from raco.scheme import Scheme
import raco.types as types

type_to_raco = {Integer: types.LONG_TYPE,
                String: types.STRING_TYPE,
                Float: types.FLOAT_TYPE,
                Boolean: types.BOOLEAN_TYPE,
                DateTime: types.DATETIME_TYPE}


raco_to_type = {types.LONG_TYPE: Integer,
                types.INT_TYPE: Integer,
                types.STRING_TYPE: String,
                types.FLOAT_TYPE: Float,
                types.DOUBLE_TYPE: Float,
                types.BOOLEAN_TYPE: Boolean,
                types.DATETIME_TYPE: DateTime}


class DBConnection(object):

    def __init__(self, connection_string='sqlite:///:memory:', echo=False):
        """Initialize a SQLLite connection."""
        self.engine = create_engine(connection_string, echo=echo)
        self.metadata = MetaData()
        self.metadata.bind = self.engine
{'fraction_non_alphanumeric': 0.0880476393024245, 'fraction_numerical': 0.0, 'mean_word_length': 2.558245083207262, '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': '862992', 'n_tokens_mistral': 670, 'n_tokens_neox': 637, 'n_words': 172}