# Path: sesql/datamodel.py
# def sql_function(func):
#     def sql_function_inner(cursor = None, execute = False, verbosity = True,
#                            include_drop = False,
#                            **kwargs):
# def create_dictionnary():
# def create_master_table():
# def create_table(table = None):
# def create_schedule_table():
# def sync_db(cursor, verbosity = 0):
# 
# Path: sesql/typemap.py
# class TypeMap(object):
#     def __init__(self):
#     def all_subclasses(klass, done = None):
#     def all_tables(self):
#     def all_classes(self):
#     def all_class_names(self):
#     def get_class_names_for(self, table):
#     def get_classes_for(self, table):
#     def get_table_for(self, klass):
#     def get_class_by_name(self, klass):


from django.core.management.base import BaseCommand
from django.core.management import call_command
from sesql import datamodel
from sesql.typemap import typemap
import settings

# SeSQL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with SeSQL.  If not, see <http://www.gnu.org/licenses/>.

"""
This should be necessary since SQL is executed in a syncdb handler, if you need
it, this will print the SQL required to generate SeSQL tables
"""


class Command(BaseCommand):
    help = "Dump the commands to create SeSQL tables"
    
    def handle(self, *apps, **options):
        """
        Handle the command
        """       
        print "BEGIN;"

        datamodel.create_dictionnary(include_drop = True)
        datamodel.create_master_table(include_drop = True)
        
        for table in typemap.all_tables():
            datamodel.create_table(table = table, include_drop = True)
            

# Path: sesql/datamodel.py
# def sql_function(func):
#     def sql_function_inner(cursor = None, execute = False, verbosity = True,
#                            include_drop = False,
#                            **kwargs):
# def create_dictionnary():
# def create_master_table():
# def create_table(table = None):
# def create_schedule_table():
# def sync_db(cursor, verbosity = 0):
# 
# Path: sesql/typemap.py
# class TypeMap(object):
#     def __init__(self):
#     def all_subclasses(klass, done = None):
#     def all_tables(self):
#     def all_classes(self):
#     def all_class_names(self):
#     def get_class_names_for(self, table):
#     def get_classes_for(self, table):
#     def get_table_for(self, klass):
#     def get_class_by_name(self, klass):


# Path: sesql/management/commands/createsesqltables.py
from django.core.management.base import BaseCommand
from django.core.management import call_command
from sesql import datamodel
from sesql.typemap import typemap
import settings


# SeSQL is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with SeSQL.  If not, see <http://www.gnu.org/licenses/>.

"""
This should be necessary since SQL is executed in a syncdb handler, if you need
it, this will print the SQL required to generate SeSQL tables
"""


class Command(BaseCommand):
    help = "Dump the commands to create SeSQL tables"
    
    def handle(self, *apps, **options):
        """
        Handle the command
        """       
        print "BEGIN;"

        datamodel.create_dictionnary(include_drop = True)
        datamodel.create_master_table(include_drop = True)
        
        for table in typemap.all_tables():
            datamodel.create_table(table = table, include_drop = True)
            

        datamodel.create_schedule_table(include_drop = True)