示例#1
0
文件: util.py 项目: umidev/autorm
def create_table(db, s_create_sql):
    """
    Create a table for an AutORM class.
    """
    Query.begin(db=db)
    Query.raw_sqlscript(s_create_sql, db=db)
    Query.commit(db=db)
示例#2
0
def create_table(db, s_create_sql):
    """
    Create a table for an AutORM class.
    """
    Query.begin(db=db)
    Query.raw_sqlscript(s_create_sql, db=db)
    Query.commit(db=db)
示例#3
0
文件: model.py 项目: umidev/autorm
 def create_table(self):
     """
     Create a table for an AutORM class.
     """
     if hasattr(self.rclass.Meta, 'create_sql'):
         s_create_sql = self.rclass.Meta.create_sql
     else:
         fields = []
         deferred = []
         for f in self.rclass._fields:
             if f.creation_deferred:
                 deferred.append(f.define(self.rclass.Meta.table))
             else:
                 fields.append(f.define())
             
         s_create_sql = """CREATE TABLE %s (%s); %s;""" % (self.rclass.Meta.table_safe, 
                                                         ", ".join(fields), ";".join(deferred))
     
     Query.begin(db=self.rclass.db)
     Query.raw_sqlscript(s_create_sql, db=self.rclass.db)
     Query.commit(db=self.rclass.db)
示例#4
0
    def create_table(self):
        """
        Create a table for an AutORM class.
        """
        if hasattr(self.rclass.Meta, 'create_sql'):
            s_create_sql = self.rclass.Meta.create_sql
        else:
            fields = []
            deferred = []
            for f in self.rclass._fields:
                if f.creation_deferred:
                    deferred.append(f.define(self.rclass.Meta.table))
                else:
                    fields.append(f.define())

            s_create_sql = """CREATE TABLE %s (%s); %s;""" % (
                self.rclass.Meta.table_safe, ", ".join(fields),
                ";".join(deferred))

        Query.begin(db=self.rclass.db)
        Query.raw_sqlscript(s_create_sql, db=self.rclass.db)
        Query.commit(db=self.rclass.db)