Database Connector

by
Odoo          
v 10.0 Third Party

18.84 €

Add to Cart
Technical name databases_connector
LicenseOPL-1

DATABASE CONNECTIONS

Used to make connections to external databases engines such as MySQL, MsSQL or PostgreSQL.

How to use...

- Create an external connection using menu "Settings / External Connections", specifying database access credentials...

- Create a model", for example:

                    class ImportEmployeesWizard(models.TransientModel):
                        _name = 'module.import_wizard_name_wizard'
                        _description = 'Wizard to import employees directory...'

                        def _get_default_connector(self):
                            return self.env['databases_connector.template'].search(
                                [('application', '=', 'rodas')], limit=1
                            ).id or False

                        connector_id = fields.Many2one(
                            'databases_connector.template',  'Database',  required=True,
                            default=_get_default_connector
                        )
                

- In the form view", you can write something like that:

                    group class="o_label_nowrap"
                        field name="connector_id"/
                    /group

                    footer
						button name="action_import" string="Import..." type="object"
                               class="oe_highlight"/
                    /footer
                

- Then, in the model" create a function, for example:

                    def action_import(self):
                        connection = self.connector_id.connect()
                        cursor = connection.cursor()

                        try:
                            # MSSQL...
                            #cursor.execute("""
                            #    SELECT TOP 1000 Id_Provincia, NombreProvincia
                            #    FROM CGT_Provincias;"""
                            #)

                            # PostgreSQL...
                            #cursor.execute("""
                            #    SELECT id, evaluated_person_id, personal_evaluation_id,
                            #           competence_profile_id, create_uid, value, write_uid,
                            #           write_date, create_date, project_id
                            #    FROM asdi_competence_profile_candidate_value;""")

                            # MySQL...
                            cursor.execute("""SELECT * FROM person LIMIT 0 , 30""")

                        except Exception,  e:
                            cursor.close()
                            raise UserError(
                                _("""The operation has not been completed. Please, check the
                                     connection of the Database and make sure to select the
                                     correct one..."""))

                        records = cursor.fetchall()
                        for row in records:
                            print row

                        connection.close()
                        return True
                
alek.cora.glez@gmail.com
Odoo Proprietary License v1.0

This software and associated files (the "Software") may only be used (executed,
modified, executed after modifications) if you have purchased a valid license
from the authors, typically via Odoo Apps, or if you have received a written
agreement from the authors of the Software (see the COPYRIGHT file).

You may develop Odoo modules that use the Software as a library (typically
by depending on it, importing it and using its resources), but without copying
any source code or material from the Software. You may distribute those
modules under the license of your choice, provided that this license is
compatible with the terms of the Odoo Proprietary License (For example:
LGPL, MIT, or proprietary licenses similar to this one).

It is forbidden to publish, distribute, sublicense, or sell copies of the Software
or modified copies of the Software.

The above copyright notice and this permission notice must be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

Please log in to comment on this module