Wednesday, September 19, 2012

Import ODBC module steps up

The import_odbc module for OpenERP was recently improved and moved  to the OpenObject Extension community project. the original module is now split in two: base_external_dbsource and import_odbc.

The import_odbc code was refactored, but keeps the same funcionality as before. Documentation was improved and some examples are provided out of the box.

The base_external_dbsource was created to isolate the logic for connecting to external databases and executing SQL queries. It's used by import_odbc, but it also enables other modules to fetch foreign data on the fly.

Additionally, the connection types supported were extended. Support for ODBC and Oracle native connections is kept, and support for other native connections was added:
  • MS SQL Server
  • MySQL
  • PostgreSQL
  • SQLite
With this evolution, it would be more fair to name the module as "import_sql" instead of the "import_odbc", but the name was kept unchanged to avoid confusing current users.

You can get the latest version of these modules from the OpenObject Extension trunk branch:
bzr branch lp:openobject-extension

Share you experiences and feature wishlists with us!

4 comments:

  1. Hi, I'm triying to import data from external Mysql DB

    I've configured correctly the connection with the server.

    I have create a new model to include the data I will import.


    How I have to do the SELECT statement?

    I'm getting this error for a simple SELECT X AS Z from Y;

    Z = is the name of the column in which I want to put this data.

    Client Traceback (most recent call last):
    File "/opt/openerp/server/openerp/addons/web/common/http.py", line 180, in dispatch
    response["result"] = method(controller, self, **self.params)
    File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1052, in call_button
    action = self.call_common(req, model, method, args, domain_id, context_id)
    File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 996, in call_common
    return self._call_kw(req, model, method, args, {})
    File "/opt/openerp/server/openerp/addons/web/controllers/main.py", line 1010, in _call_kw
    return getattr(req.session.model(model), method)(*args, **kwargs)
    File "/opt/openerp/server/openerp/addons/web/common/openerplib/main.py", line 250, in proxy
    args, kw)
    File "/opt/openerp/server/openerp/addons/web/common/openerplib/main.py", line 117, in proxy
    result = self.connector.send(self.service_name, method, *args)
    File "/opt/openerp/server/openerp/addons/web/common/http.py", line 608, in send
    raise xmlrpclib.Fault(openerp.tools.exception_to_unicode(e), formatted_info)


    Server Traceback (most recent call last):
    File "/opt/openerp/server/openerp/addons/web/common/http.py", line 593, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
    File "/opt/openerp/server/openerp/netsvc.py", line 360, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
    File "/opt/openerp/server/openerp/service/web_services.py", line 586, in dispatch
    res = fn(db, uid, *params)
    File "/opt/openerp/server/openerp/osv/osv.py", line 186, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
    File "/opt/openerp/server/openerp/osv/osv.py", line 129, in wrapper
    return f(self, dbname, *args, **kwargs)
    File "/opt/openerp/server/openerp/osv/osv.py", line 195, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
    File "/opt/openerp/server/openerp/osv/osv.py", line 183, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
    File "/opt/openerp/server/openerp/addons/import_odbc/import_odbc.py", line 187, in import_run
    self.write(cr, uid, [obj.id], log)
    File "/opt/openerp/server/openerp/osv/orm.py", line 3927, in write
    'where id IN %s', upd1 + [sub_ids])
    File "/opt/openerp/server/openerp/sql_db.py", line 152, in wrapper
    return f(self, *args, **kwargs)
    File "/opt/openerp/server/openerp/sql_db.py", line 212, in execute
    res = self._obj.execute(query, params)
    InternalError: current transaction is aborted, commands ignored until end of transaction block


    ReplyDelete
  2. Hi. The "InternalError: current transaction is aborted" error does not bring me any immediate idea of what might be wrong. I suggest you report a bug at https://bugs.launchpad.net/openobject-extension. Maybe a contributor using MySQL can be helpful on this.

    ReplyDelete
  3. Hi,
    I am trying to connect to Oracle database using base_external_dbsource. I am successfully installed that module and cx_Oracle inorder to communicate with Python.
    I can import cx_Oracle in Pythonshell using terminal, But i am getting an error while i am using eclipse :"ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory"
    Please give me a solution.. Thank you.

    ReplyDelete
    Replies
    1. Sorry, I'm not an Eclipse user and I haven't found that error before, so I'm afraid I can't help.

      Delete