如何通过SQLAlchemy生成表,如django manage.py inspectdb?

时间:2019-03-14 10:41:17

标签: python django sqlalchemy

在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做同样的事情?

0 个答案:

没有答案