在Django中与mysql连接时,我们可以使用public function import()
{
$url = $this->get_data();
$xml = new SimpleXMLElement($url);
$json_string = json_encode($xml);
$advertisers = json_decode($json_string, TRUE);
$this->import_advertiser($advertisers);
}
public function import_advertiser($advertisers = [])
{
echo $advertisers;
if($advertisers) {
foreach($advertisers as $advertiser)
{
$attr = [
'advertiser-id' => $advertiser->advertiser-id,
'advertiser-name' => $advertiser->advertiser-name,
'program-url' => $advertiser->program-url,
'relationship-status' => $advertiser->relationship-status,
];
$this->db->replace($this->table_program_name, $attr);
}
}}
自动生成指定的表。
是否可以使用SQLAlchemy做同样的事情?