def handle(self): view = View(App()) class_directory = 'databases/seeds/{}_table_seeder.py'.format( self.argument('table')) if not make_directory(class_directory): pass # return self.error('{0} Seeder Already Exists!'.format(self.argument('table'))) conn = DB.get_schema_manager().list_table_columns( self.argument('table')) # docstring = '"""Model Definition (generated with love by Masonite) \n\n' # for name, column in conn.items(): # length = '({})'.format(column._length) if column._length else '' # docstring += '{}: {}{} default: {}\n'.format( # name, column.get_type(), length, column.get_default()) f = open(class_directory, 'w+') if view.exists('scaffold/seed'): f.write( view.render('scaffold/seed', { 'table': self.argument('table'), 'columns': conn.items(), }).rendered_template) self.info('Seeder Created Successfully!') return f.close()
def handle(self): conn = DB.get_schema_manager().list_table_columns( self.argument('table')) docstring = '"""Model Definition (generated with love by Masonite) \n\n' for name, column in conn.items(): length = '({})'.format(column._length) if column._length else '' docstring += '{}: {}{} default: {}\n'.format( name, column.get_type(), length, column.get_default()) print(docstring + '"""')
def handle(self): from config.database import DB if self.option("connection") == "default": conn = DB.get_schema_manager().list_table_columns( self.argument("table")) else: conn = (DB.connection(self.option( "connection")).get_schema_manager().list_table_columns( self.argument("table"))) docstring = '"""Model Definition (generated with love by Masonite) \n\n' for name, column in conn.items(): length = "({})".format(column._length) if column._length else "" docstring += "{}: {}{} default: {}\n".format( name, column.get_type(), length, column.get_default()) print(docstring + '"""')
def show_user(self, view: View): conn = DB.get_schema_manager().list_table_columns('users') return view.render('{0}/management/add_user'.format(self.template_prefix), {'schema': conn})