<commit_before><commit_msg>added a SQLalchemy wrapper class<commit_after>"""
independant to DB implementations
"""
from sqlalchemy import create_engine, inspect
import pandas as pd

class SqlEngine:
  """
  wraper class of sqlalchemy engine
  """
  @classmethod
  def create(cls, uri):
    con = create_engine(uri)
    return cls(con)
  @classmethod
  def copy(cls, other):
    """
    create and copy from another item in as collection
    """
    return cls(other._connection)
  def __init__(self, con):
    self._db_uri = con.url
    self._connection = con
    self._inspector = inspect(self._connection)

  def query(self, sql):
    return pd.read_sql_query(sql, self._connection)
  def insert(self, name, df):
    df.to_sql(name, self._connection)
{'fraction_non_alphanumeric': 0.1023936170212766, 'fraction_numerical': 0.0, 'mean_word_length': 3.8896103896103895, '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': '298041', 'n_tokens_mistral': 239, 'n_tokens_neox': 235, 'n_words': 69}