...
Codeblock | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
# -*- coding: UTF-8 -*- ############################################################################## # # Python Script for Odoo, Open Source Management Solution # Copyright (C) 2014-now Equitania Software GmbH(<http://www.equitania.de>). # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import xmlrpclib from faker import Faker import time username = "admin" pwd = "pw" dbname = "dbname" baseurl = "http://localhost:8069" sock_common = xmlrpclib.ServerProxy(baseurl + "/xmlrpc/common") uid = sock_common.login(dbname, username, pwd) sock = xmlrpclib.ServerProxy(baseurl + "/xmlrpc/object") name_list = [] i = 1 start_time = time.time() _totalcount = 1000 fake = Faker('de_DE') for i in range(_totalcount): name = fake.company() external_id = 'import.res_partner' + str(i) new_name_list = [external_id, name] name_list.append(new_name_list) print"name_list: ", name_list sock.execute(dbname, uid, pwd, 'res.partner', 'load', ['id', 'name'], name_list, {'context': {}}) # Store end time end_time = time.time() # Calculate the execution time and print the result print("%.10f seconds" % (end_time - start_time)) # sock.execute(dbname, uid, pwd, 'res.partner', 'load', ['id','name'], # [ # #Update # [external_id,'Testpartner_1'], # #Insert # ['my_partner.external_id2','Testpartner_2'], # ] # , {'context': {}}) print 'Fertig!' |
Nach dem durchgeführten Import sieht man nach der Ausführung des nachfolgenden SQL-Statements:
Codeblock | ||||||
---|---|---|---|---|---|---|
| ||||||
Select * From ir_model_data where model='res.partner' |
einen Auschnitt der erstellten Datensätze in dem Datenmodell 'ir.model.data'. Hier ist auch zu erkennen, wie die externe ID zusammengesetzt (module.name der Tabelle 'ir.model.data') wird.
Datensätze res.partner | 100 | 100 | 1000 |
---|---|---|---|
create | 22,53 sec | 25,28 sec | 251,84 sec |
load | 15,68 sec | 15,63 sec | 169,71 sec |
Performancegewinn | ~ 30,4 % | ~ 38,2 % | ~ 32,6 % |
Diese Tabelle zeigt die Ergebnisse unseres kleinen Tests. Es ist klar zu sehen, dass durch die load-Methode ein Performancegewinn von ~ 34 % möglich ist.
...