SQLAlchemy无法识别db.Model

时间:2018-08-10 23:17:48

标签: python flask-sqlalchemy

我正在尝试仅使用python脚本设置sqlalchemy。 输出如下:

 var collection = {
  "2548": {
    "album": "Slippery When Wet",
    "artist": "Bon Jovi",
    "tracks": [ 
      "Let It Rock", 
      "You Give Love a Bad Name" 
    ]
  },
  "2468": {
    "album": "1999",
    "artist": "Prince",
    "tracks": [ 
      "1999", 
      "Little Red Corvette" 
    ]
  },
  "1245": {
    "artist": "Robert Palmer",
    "tracks": [ ]
  },
  "5439": {
    "album": "ABBA Gold"
  }
};

function updateRecords(id, prop, value) {
  // Exit function if required items are missing
  if (!id || !collection) return;

  // We can't assume that collection will have [id]
  if (!collection.hasOwnProperty(id)) {
    collection[id] = [];
  }

  // Create an object reference to the id in the collection
  const reference = collection[id];

  // Now it's pretty straight forward after
  if (prop === "tracks" && value && typeof value === "string") {
    if (reference.hasOwnProperty(prop)) {
      reference[prop].push(value);
    } else {
      reference[prop] = [value];
    }
  } else if (value) {
    reference[prop] = value;
  } else {
    delete reference[prop];
  }

  return collection;
}

// Alter values below to test your code
updateRecords(2468, "tracks", "ABBA");
updateRecords(2468, "tracks", ["BETA"]);
updateRecords(2468, "tracks", "");

我知道这可能是一个noobie请求。

NameError: name 'db' is not defined

1 个答案:

答案 0 :(得分:0)

在使用methods: { myclick: function () { for (obj of Object.values(this.main_level)) { console.log(obj) } } } 变量之前先对其进行设置

db