對象的'wb'(以及顯然所有上級對象)加載並保存信息,但是獲取數據庫物理的樹模型根本沒有加載。到目前爲止,互聯網搜索讓我感覺到了bipkis。 (我打算編寫一個例程來測試某些列的存在,並以編程方式添加適當的觸發器,我使用正則表達式和數據庫導出計算出了一個kludge,但這有點兒不合適)。在MySQL Workbench 5.2.34的Python腳本中,grt.root.wb沒有物理模型
缺少某種形式的簡單激活? (連接也許)
下失敗,錯誤 「AttributeError的: 'NoneType' 對象有沒有屬性 'physicalModels'」:
# -*- coding: utf-8 -*-
# MySQL Workbench Python script
# <description>
# Written in MySQL Workbench 5.2.34
import grt
#import mforms #??
stOut=""
stTrigger="""
delimiter $$
create trigger `docdb_mk2`.tsi_{t} before insert on `docdb_mk2`.`{t}`
for each row begin
set new.inserted=now();
end$$"""
# iterate through all tables from schema"""
schema = grt.root.wb.doc.physicalModels[0].catalog.schemata[0]
for table in schema.tables:
#print table.name
#if table.
#check to make sure both inserted and Updated are in the table
#Since I have no clue how to do that in here, I'll skip it for now.
stOut=stOut+stTrigger(t=table.name)
即使失敗:
# -*- coding: utf-8 -*-
# MySQL Workbench Python script
# <description>
# Written in MySQL Workbench 5.2.34
import grt
#import mforms
# iterate through all schemas
for schema in grt.root.wb.doc.physicalModels[0].catalog.schemata:
print schema.name
請注意,我現在不會就我的SQL尋求建議,僅僅是在腳本編寫中這個令人惱怒的障礙。
編輯:顯然,通過在UI中加載這些元素來加載一些對象。如果有某種方法讓它們加載其他方式,我會很高興知道,但是看起來如果從主工作臺屏幕加載腳本模塊,您會看到一個部分初始化的wb對象。如果您從不同的子系統(如數據建模模塊,(腳本>運行工作臺腳本文件...))加載其他部件,則其他部件將加載並開始工作。嗯。
所以......它似乎很重要你如何_load_腳本編輯器。 如上所述,我遇到了麻煩。但是,在閱讀完這些之後,我從模型編輯器中加載了腳本編輯器,並且沒有大驚小怪。 –
我接受這是最好的答案,因爲通過它我發現了一個部分解決方案,但我仍然在想。 –