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)
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)
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)