# Path: mamba/core/adapters.py
# class MambaSQLAdapter:
# 
#     implements(IMambaSQL)
# 
#     def __init__(self, original):
#         self.original = original
# 
#         if not hasattr(self.original.model, '_storm_columns'):
#             get_obj_info(self.original.model)
# 
#     def parse_column(self, column):
#         """Parse a Storm column to the correct SQL value
#         """
# 
#         return self.original.parse_column(column)
# 
#     def detect_primary_key(self):
#         """Detect and reeturn the primary key for the table
#         """
# 
#         return self.original.detect_primary_key()
# 
#     def create_table(self):
#         """
#         Return the SQL syntax string to create a table to the selected
#         underlying database system
#         """
# 
#         return self.original.create_table()
# 
#     def drop_table(self):
#         """
#         Return the SQL syntax string to drop a table from the selected
#         underlying database system
#         """
# 
#         return self.original.drop_table()
# 
#     def insert_data(self, scheme):
#         """Return the SQL syntax string to insert data that populate a table
#         """
# 
#         return self.original.insert_data(scheme)
# 
#     def parse_references(self):
#         """Return the SQL syntax to create foreign keys for PostgreSQL
#         """
# 
#         return self.original.parse_references()
# 
#     def parse_indexes(self):
#         """Return the SQL syntax to create indexes for PostgreSQL or SQLite
#         """
# 
#         return self.original.parse_indexes()


import inspect
from sqlite3 import sqlite_version_info
from storm import properties
from twisted.python import components
from storm.references import Reference
from singledispatch import singledispatch
from mamba.utils import config
from mamba.core.interfaces import IMambaSQL
from mamba.core.adapters import MambaSQLAdapter
from mamba.enterprise.common import CommonSQL, NativeEnum
        if (config.Database().create_table_behaviours.get('drop_table')
            and not config.Database().create_table_behaviours.get(
                'create_if_not_exists')):
            query = '{};\n{}'.format(
                self.drop_table(),
                query
            )

        return query

    def drop_table(self):
        """Return SQLite syntax for drop this model table
        """

        existance = config.Database().drop_table_behaviours.get(
            'drop_if_exists', True)

        query = 'DROP TABLE {}{}'.format(
            'IF EXISTS ' if existance else '',
            self.model.__storm_table__
        )

        return query

    @staticmethod
    def register():
        """Register this component
        """

        try:

# Path: mamba/core/adapters.py
# class MambaSQLAdapter:
# 
#     implements(IMambaSQL)
# 
#     def __init__(self, original):
#         self.original = original
# 
#         if not hasattr(self.original.model, '_storm_columns'):
#             get_obj_info(self.original.model)
# 
#     def parse_column(self, column):
#         """Parse a Storm column to the correct SQL value
#         """
# 
#         return self.original.parse_column(column)
# 
#     def detect_primary_key(self):
#         """Detect and reeturn the primary key for the table
#         """
# 
#         return self.original.detect_primary_key()
# 
#     def create_table(self):
#         """
#         Return the SQL syntax string to create a table to the selected
#         underlying database system
#         """
# 
#         return self.original.create_table()
# 
#     def drop_table(self):
#         """
#         Return the SQL syntax string to drop a table from the selected
#         underlying database system
#         """
# 
#         return self.original.drop_table()
# 
#     def insert_data(self, scheme):
#         """Return the SQL syntax string to insert data that populate a table
#         """
# 
#         return self.original.insert_data(scheme)
# 
#     def parse_references(self):
#         """Return the SQL syntax to create foreign keys for PostgreSQL
#         """
# 
#         return self.original.parse_references()
# 
#     def parse_indexes(self):
#         """Return the SQL syntax to create indexes for PostgreSQL or SQLite
#         """
# 
#         return self.original.parse_indexes()


# Path: mamba/enterprise/sqlite.py
import inspect
from sqlite3 import sqlite_version_info
from storm import properties
from twisted.python import components
from storm.references import Reference
from singledispatch import singledispatch
from mamba.utils import config
from mamba.core.interfaces import IMambaSQL
from mamba.core.adapters import MambaSQLAdapter
from mamba.enterprise.common import CommonSQL, NativeEnum

        if (config.Database().create_table_behaviours.get('drop_table')
            and not config.Database().create_table_behaviours.get(
                'create_if_not_exists')):
            query = '{};\n{}'.format(
                self.drop_table(),
                query
            )

        return query

    def drop_table(self):
        """Return SQLite syntax for drop this model table
        """

        existance = config.Database().drop_table_behaviours.get(
            'drop_if_exists', True)

        query = 'DROP TABLE {}{}'.format(
            'IF EXISTS ' if existance else '',
            self.model.__storm_table__
        )

        return query

    @staticmethod
    def register():
        """Register this component
        """

        try:

            components.registerAdapter(MambaSQLAdapter, SQLite, IMambaSQL)