<gh_stars>0
from flask_app.config.mysqlconnection import connectToMySQL

class Ninja:

    # Here: aligning the tables and the class attributes.
    # This way, when that data comes in - we can then parse that
    # into the object.
    # Parsing of the data is bringing this back in to the dojo object,
    # or the ninja object.
    def __init__(self, data):
        self.id = data['id']
        self.first_name = data['first_name']
        self.last_name = data['last_name']
        self.age = data['age']
        self.created_at = data['created_at']
        self.updated_at = data['updated_at']

    @classmethod
    def save(cls,data):
        query = "INSERT INTO ninjas (first_name, last_name, age, dojo_id) VALUES (%(first_name)s, %(last_name)s, %(age)s, %(dojo_id)s);"
        return connectToMySQL('dojo_ninjas').query_db(query,data)

from flask_app.config.mysqlconnection import connectToMySQL

class Ninja:

    # Here: aligning the tables and the class attributes.
    # This way, when that data comes in - we can then parse that
    # into the object.
    # Parsing of the data is bringing this back in to the dojo object,
    # or the ninja object.
    def __init__(self, data):
        self.id = data['id']
        self.first_name = data['first_name']
        self.last_name = data['last_name']
        self.age = data['age']
        self.created_at = data['created_at']
        self.updated_at = data['updated_at']

    @classmethod
    def save(cls,data):
        query = "INSERT INTO ninjas (first_name, last_name, age, dojo_id) VALUES (%(first_name)s, %(last_name)s, %(age)s, %(dojo_id)s);"
        return connectToMySQL('dojo_ninjas').query_db(query,data)
# Here: aligning the tables and the class attributes. # This way, when that data comes in - we can then parse that # into the object. # Parsing of the data is bringing this back in to the dojo object, # or the ninja object.