# Path: sentry/db/backends/base.py
# class SentryBackend(object):
#     def _get_schema_name(self, schema):
#         return schema.__name__.lower()
# 
#     def _get_composite_key(self, **keys):
#         return hashlib.md5(';'.join('%s=%s' % (k, v) for k, v in keys.iteritems())).hexdigest()
# 
#     def generate_key(self, schema):
#         return uuid.uuid4().hex
# 
# Path: sentry/db/backends/sqlalchemy/models.py
# def create_sqlalchemy_def(metadata, model):
# def create_sqlalchemy_metadata_def(metadata, model):


from sentry.db.backends.base import SentryBackend
from sqlalchemy import create_engine
from sqlalchemy.sql import select
from sentry.db.backends.sqlalchemy.models import metadata, model_map
import datetime
"""
sentry.db.backends.sqlalchemy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import absolute_import





class SQLAlchemyBackend(SentryBackend):
    def __init__(self, uri, **kwargs):
        self.engine = create_engine(uri, **kwargs)

    def create_model(self, schema):
        metadata.create(model_map[schema])

    ## Hash table lookups

    def add(self, schema, **values):
        # generates a pk and sets the values
        pk = self.generate_key(schema)

# Path: sentry/db/backends/base.py
# class SentryBackend(object):
#     def _get_schema_name(self, schema):
#         return schema.__name__.lower()
# 
#     def _get_composite_key(self, **keys):
#         return hashlib.md5(';'.join('%s=%s' % (k, v) for k, v in keys.iteritems())).hexdigest()
# 
#     def generate_key(self, schema):
#         return uuid.uuid4().hex
# 
# Path: sentry/db/backends/sqlalchemy/models.py
# def create_sqlalchemy_def(metadata, model):
# def create_sqlalchemy_metadata_def(metadata, model):


# Path: sentry/db/backends/sqlalchemy/backend.py
from sentry.db.backends.base import SentryBackend
from sqlalchemy import create_engine
from sqlalchemy.sql import select
from sentry.db.backends.sqlalchemy.models import metadata, model_map
import datetime

"""
sentry.db.backends.sqlalchemy
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import absolute_import





class SQLAlchemyBackend(SentryBackend):
    def __init__(self, uri, **kwargs):
        self.engine = create_engine(uri, **kwargs)

    def create_model(self, schema):
        metadata.create(model_map[schema])

    ## Hash table lookups

    def add(self, schema, **values):
        # generates a pk and sets the values
        pk = self.generate_key(schema)

        table = model_map[schema]