diff --git a/base_external_dbsource_sqlite/README.rst b/base_external_dbsource_sqlite/README.rst new file mode 100644 index 00000000..7e534a29 --- /dev/null +++ b/base_external_dbsource_sqlite/README.rst @@ -0,0 +1,126 @@ +================================= +External Database Source - SQLite +================================= + +.. + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! source digest: sha256:be42980ba34bb6865c363361ab0af4b4c54884df329f861dd1d906f1723643ab + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-LGPL--3-blue.png + :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html + :alt: License: LGPL-3 +.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fserver--backend-lightgray.png?logo=github + :target: https://github.com/OCA/server-backend/tree/17.0/base_external_dbsource_sqlite + :alt: OCA/server-backend +.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png + :target: https://translation.odoo-community.org/projects/server-backend-17-0/server-backend-17-0-base_external_dbsource_sqlite + :alt: Translate me on Weblate +.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png + :target: https://runboat.odoo-community.org/builds?repo=OCA/server-backend&target_branch=17.0 + :alt: Try me on Runboat + +|badge1| |badge2| |badge3| |badge4| |badge5| + +This module extends ``base_external_dbsource``, allowing you to connect +to foreign SQLite databases using SQLAlchemy. + +**Table of contents** + +.. contents:: + :local: + +Installation +============ + +To install this module, you need to: + +- Install ``sqlalchemy`` python library + +Configuration +============= + +To configure this module, you need to: + +1. Database sources can be configured in Settings > Configuration -> + Data sources. + +Usage +===== + +To use this module: + +- Go to Settings > Database Structure > Database Sources +- Click on Create to enter the following information: +- Datasource name  +- Pasword +- Connector: Choose the database to which you want to connect +- Connection string: Specify how to connect to database + +Known issues / Roadmap +====================== + +- Add X.509 authentication + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +`feedback `_. + +Do not contact contributors directly about support or help with technical issues. + +Credits +======= + +Authors +------- + +* Daniel Reis +* LasLabs + +Contributors +------------ + +- Daniel Reis +- Maxime Chambreuil +- Gervais Naoussi +- Dave Lasley +- `Tecnativa `__: + + - Sergio Teruel + +- Andrea Cattalani (`Moduon `__) + +Maintainers +----------- + +This module is maintained by the OCA. + +.. image:: https://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: https://odoo-community.org + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +.. |maintainer-anddago78| image:: https://github.com/anddago78.png?size=40px + :target: https://github.com/anddago78 + :alt: anddago78 + +Current `maintainer `__: + +|maintainer-anddago78| + +This module is part of the `OCA/server-backend `_ project on GitHub. + +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/base_external_dbsource_sqlite/__init__.py b/base_external_dbsource_sqlite/__init__.py new file mode 100644 index 00000000..0650744f --- /dev/null +++ b/base_external_dbsource_sqlite/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/base_external_dbsource_sqlite/__manifest__.py b/base_external_dbsource_sqlite/__manifest__.py new file mode 100644 index 00000000..fab1727e --- /dev/null +++ b/base_external_dbsource_sqlite/__manifest__.py @@ -0,0 +1,16 @@ +# Copyright <2011> +# Copyright 2016 LasLabs Inc. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). +{ + "name": "External Database Source - SQLite", + "version": "17.0.1.0.0", + "category": "Tools", + "author": "Daniel Reis, LasLabs, Odoo Community Association (OCA)", + "maintainers": ["anddago78"], + "website": "https://github.com/OCA/server-backend", + "license": "LGPL-3", + "depends": ["base_external_dbsource"], + "external_dependencies": {"python": ["sqlalchemy"]}, + "demo": ["demo/base_external_dbsource.xml"], + "installable": True, +} diff --git a/base_external_dbsource_sqlite/demo/base_external_dbsource.xml b/base_external_dbsource_sqlite/demo/base_external_dbsource.xml new file mode 100644 index 00000000..5ec0b7d3 --- /dev/null +++ b/base_external_dbsource_sqlite/demo/base_external_dbsource.xml @@ -0,0 +1,9 @@ + + + + SQLite Demo + sqlite:// + + sqlite + + diff --git a/base_external_dbsource_sqlite/i18n/base_external_dbsource_sqlite.pot b/base_external_dbsource_sqlite/i18n/base_external_dbsource_sqlite.pot new file mode 100644 index 00000000..4429f013 --- /dev/null +++ b/base_external_dbsource_sqlite/i18n/base_external_dbsource_sqlite.pot @@ -0,0 +1,36 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_sqlite +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,field_description:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model,name:base_external_dbsource_sqlite.model_base_external_dbsource +msgid "External Database Sources" +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,help:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields.selection,name:base_external_dbsource_sqlite.selection__base_external_dbsource__connector__sqlite +msgid "SQLite" +msgstr "" diff --git a/base_external_dbsource_sqlite/i18n/de.po b/base_external_dbsource_sqlite/i18n/de.po new file mode 100644 index 00000000..f6bcab45 --- /dev/null +++ b/base_external_dbsource_sqlite/i18n/de.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_sqlite +# +# Translators: +# Rudolf Schnapka , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-10 00:47+0000\n" +"PO-Revision-Date: 2017-05-10 00:47+0000\n" +"Last-Translator: Rudolf Schnapka , 2017\n" +"Language-Team: German (https://www.transifex.com/oca/teams/23907/de/)\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,field_description:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model,name:base_external_dbsource_sqlite.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Externe Datenbankquellen" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,help:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields.selection,name:base_external_dbsource_sqlite.selection__base_external_dbsource__connector__sqlite +msgid "SQLite" +msgstr "" diff --git a/base_external_dbsource_sqlite/i18n/es.po b/base_external_dbsource_sqlite/i18n/es.po new file mode 100644 index 00000000..036e4078 --- /dev/null +++ b/base_external_dbsource_sqlite/i18n/es.po @@ -0,0 +1,44 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_sqlite +# +# Translators: +# Fernando Lara , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-02-22 00:54+0000\n" +"PO-Revision-Date: 2023-08-28 09:10+0000\n" +"Last-Translator: Ivorra78 \n" +"Language-Team: Spanish (https://www.transifex.com/oca/teams/23907/es/)\n" +"Language: es\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,field_description:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "Connector" +msgstr "Conector" + +#. module: base_external_dbsource_sqlite +#: model:ir.model,name:base_external_dbsource_sqlite.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Fuentes externas de la base de datos" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,help:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" +"Si falta un conector en la lista, compruebe el registro del servidor para " +"confirmar que se han detectado los componentes necesarios." + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields.selection,name:base_external_dbsource_sqlite.selection__base_external_dbsource__connector__sqlite +msgid "SQLite" +msgstr "SQLite" diff --git a/base_external_dbsource_sqlite/i18n/hr.po b/base_external_dbsource_sqlite/i18n/hr.po new file mode 100644 index 00000000..bcdf8942 --- /dev/null +++ b/base_external_dbsource_sqlite/i18n/hr.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_sqlite +# +# Translators: +# Bole , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-05-10 00:47+0000\n" +"PO-Revision-Date: 2017-05-10 00:47+0000\n" +"Last-Translator: Bole , 2017\n" +"Language-Team: Croatian (https://www.transifex.com/oca/teams/23907/hr/)\n" +"Language: hr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,field_description:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model,name:base_external_dbsource_sqlite.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Vanjske baze" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,help:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields.selection,name:base_external_dbsource_sqlite.selection__base_external_dbsource__connector__sqlite +msgid "SQLite" +msgstr "" diff --git a/base_external_dbsource_sqlite/i18n/it.po b/base_external_dbsource_sqlite/i18n/it.po new file mode 100644 index 00000000..b0cfc3a9 --- /dev/null +++ b/base_external_dbsource_sqlite/i18n/it.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_sqlite +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 16.0\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: 2024-01-05 11:35+0000\n" +"Last-Translator: mymage \n" +"Language-Team: none\n" +"Language: it\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,field_description:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "Connector" +msgstr "Connettore" + +#. module: base_external_dbsource_sqlite +#: model:ir.model,name:base_external_dbsource_sqlite.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Origini database esterne" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,help:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" +"Se il connettore è mancante dalla lista, controllare il log del server per " +"avere conferma che i componenti richiesti siano stati rilevati." + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields.selection,name:base_external_dbsource_sqlite.selection__base_external_dbsource__connector__sqlite +msgid "SQLite" +msgstr "SQLite" diff --git a/base_external_dbsource_sqlite/i18n/nl_NL.po b/base_external_dbsource_sqlite/i18n/nl_NL.po new file mode 100644 index 00000000..46362e35 --- /dev/null +++ b/base_external_dbsource_sqlite/i18n/nl_NL.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_sqlite +# +# Translators: +# Peter Hageman , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-06-22 01:11+0000\n" +"PO-Revision-Date: 2017-06-22 01:11+0000\n" +"Last-Translator: Peter Hageman , 2017\n" +"Language-Team: Dutch (Netherlands) (https://www.transifex.com/oca/" +"teams/23907/nl_NL/)\n" +"Language: nl_NL\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,field_description:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model,name:base_external_dbsource_sqlite.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Externe databasebronnen" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,help:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields.selection,name:base_external_dbsource_sqlite.selection__base_external_dbsource__connector__sqlite +msgid "SQLite" +msgstr "" diff --git a/base_external_dbsource_sqlite/i18n/pt_BR.po b/base_external_dbsource_sqlite/i18n/pt_BR.po new file mode 100644 index 00000000..6baeb1ec --- /dev/null +++ b/base_external_dbsource_sqlite/i18n/pt_BR.po @@ -0,0 +1,46 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_sqlite +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-21 04:22+0000\n" +"PO-Revision-Date: 2024-05-22 15:40+0000\n" +"Last-Translator: Rodrigo Macedo \n" +"Language-Team: Portuguese (Brazil) (https://www.transifex.com/oca/teams/" +"23907/pt_BR/)\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=n > 1;\n" +"X-Generator: Weblate 4.17\n" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,field_description:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "Connector" +msgstr "Conector" + +#. module: base_external_dbsource_sqlite +#: model:ir.model,name:base_external_dbsource_sqlite.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Fontes Banco de Dados Externo" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,help:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" +"Se um conector estiver ausente na lista, verifique o log do servidor para " +"confirmar se os componentes necessários foram detectados." + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields.selection,name:base_external_dbsource_sqlite.selection__base_external_dbsource__connector__sqlite +msgid "SQLite" +msgstr "SQLite" diff --git a/base_external_dbsource_sqlite/i18n/sl.po b/base_external_dbsource_sqlite/i18n/sl.po new file mode 100644 index 00000000..b501d353 --- /dev/null +++ b/base_external_dbsource_sqlite/i18n/sl.po @@ -0,0 +1,42 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_sqlite +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-21 04:22+0000\n" +"PO-Revision-Date: 2017-01-21 04:22+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Slovenian (https://www.transifex.com/oca/teams/23907/sl/)\n" +"Language: sl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n" +"%100==4 ? 2 : 3);\n" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,field_description:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model,name:base_external_dbsource_sqlite.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Viri zunanjih podatkovnih baz" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,help:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields.selection,name:base_external_dbsource_sqlite.selection__base_external_dbsource__connector__sqlite +msgid "SQLite" +msgstr "" diff --git a/base_external_dbsource_sqlite/i18n/tr.po b/base_external_dbsource_sqlite/i18n/tr.po new file mode 100644 index 00000000..13b13096 --- /dev/null +++ b/base_external_dbsource_sqlite/i18n/tr.po @@ -0,0 +1,41 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * base_external_dbsource_sqlite +# +# Translators: +# OCA Transbot , 2017 +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 10.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2017-01-21 04:22+0000\n" +"PO-Revision-Date: 2017-01-21 04:22+0000\n" +"Last-Translator: OCA Transbot , 2017\n" +"Language-Team: Turkish (https://www.transifex.com/oca/teams/23907/tr/)\n" +"Language: tr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,field_description:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "Connector" +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model,name:base_external_dbsource_sqlite.model_base_external_dbsource +msgid "External Database Sources" +msgstr "Dış veritabanı kaynakları" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields,help:base_external_dbsource_sqlite.field_base_external_dbsource__connector +msgid "" +"If a connector is missing from the list, check the server log to confirm " +"that the required components were detected." +msgstr "" + +#. module: base_external_dbsource_sqlite +#: model:ir.model.fields.selection,name:base_external_dbsource_sqlite.selection__base_external_dbsource__connector__sqlite +msgid "SQLite" +msgstr "" diff --git a/base_external_dbsource_sqlite/models/__init__.py b/base_external_dbsource_sqlite/models/__init__.py new file mode 100644 index 00000000..91032fcb --- /dev/null +++ b/base_external_dbsource_sqlite/models/__init__.py @@ -0,0 +1 @@ +from . import base_external_dbsource diff --git a/base_external_dbsource_sqlite/models/base_external_dbsource.py b/base_external_dbsource_sqlite/models/base_external_dbsource.py new file mode 100644 index 00000000..fc6ba2f1 --- /dev/null +++ b/base_external_dbsource_sqlite/models/base_external_dbsource.py @@ -0,0 +1,44 @@ +# Copyright 2011 Daniel Reis +# Copyright 2016 LasLabs Inc. +# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html). +import sqlalchemy + +from odoo import fields, models + + +class BaseExternalDbsource(models.Model): + """It provides logic for connection to a SQLite data source.""" + + _inherit = "base.external.dbsource" + + PWD_STRING_SQLITE = "Password=%s;" + connector = fields.Selection( + selection_add=[("sqlite", "SQLite")], ondelete={"sqlite": "cascade"} + ) + + def connection_close_sqlite(self, connection): + return connection.close() + + def connection_open_sqlite(self): + return self._connection_open_sqlalchemy() + + def execute_sqlite(self, sqlquery, sqlparams, metadata): + return self._execute_sqlalchemy(sqlquery, sqlparams, metadata) + + def _connection_open_sqlalchemy(self): + return sqlalchemy.create_engine(self.conn_string_full).connect() + + def _execute_sqlalchemy(self, sqlquery, sqlparams, metadata): + rows, cols = list(), list() + for record in self: + with record.connection_open() as connection: + if sqlparams is None: + cur = connection.execute(sqlquery) + else: + cur = connection.execute(sqlquery, sqlparams) + if metadata: + cols = list(cur.keys()) + # If the query doesn't return rows, trying to get them anyway + # will raise an exception `sqlalchemy.exc.ResourceClosedError` + rows = [r for r in cur] if cur.returns_rows else [] + return rows, cols diff --git a/base_external_dbsource_sqlite/pyproject.toml b/base_external_dbsource_sqlite/pyproject.toml new file mode 100644 index 00000000..4231d0cc --- /dev/null +++ b/base_external_dbsource_sqlite/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["whool"] +build-backend = "whool.buildapi" diff --git a/base_external_dbsource_sqlite/readme/CONFIGURE.md b/base_external_dbsource_sqlite/readme/CONFIGURE.md new file mode 100644 index 00000000..8096c95f --- /dev/null +++ b/base_external_dbsource_sqlite/readme/CONFIGURE.md @@ -0,0 +1,4 @@ +To configure this module, you need to: + +1. Database sources can be configured in Settings \> Configuration -\> + Data sources. diff --git a/base_external_dbsource_sqlite/readme/CONTRIBUTORS.md b/base_external_dbsource_sqlite/readme/CONTRIBUTORS.md new file mode 100644 index 00000000..c6e2c6a0 --- /dev/null +++ b/base_external_dbsource_sqlite/readme/CONTRIBUTORS.md @@ -0,0 +1,7 @@ +- Daniel Reis \<\> +- Maxime Chambreuil \<\> +- Gervais Naoussi \<\> +- Dave Lasley \<\> +- [Tecnativa](https://www.tecnativa.com): + - Sergio Teruel +- Andrea Cattalani ([Moduon](https://www.moduon.team/)) diff --git a/base_external_dbsource_sqlite/readme/DESCRIPTION.md b/base_external_dbsource_sqlite/readme/DESCRIPTION.md new file mode 100644 index 00000000..d5855938 --- /dev/null +++ b/base_external_dbsource_sqlite/readme/DESCRIPTION.md @@ -0,0 +1,2 @@ +This module extends `base_external_dbsource`, allowing you to connect to +foreign SQLite databases using SQLAlchemy. diff --git a/base_external_dbsource_sqlite/readme/INSTALL.md b/base_external_dbsource_sqlite/readme/INSTALL.md new file mode 100644 index 00000000..326515e9 --- /dev/null +++ b/base_external_dbsource_sqlite/readme/INSTALL.md @@ -0,0 +1,3 @@ +To install this module, you need to: + +- Install `sqlalchemy` python library diff --git a/base_external_dbsource_sqlite/readme/ROADMAP.md b/base_external_dbsource_sqlite/readme/ROADMAP.md new file mode 100644 index 00000000..9ae5c4de --- /dev/null +++ b/base_external_dbsource_sqlite/readme/ROADMAP.md @@ -0,0 +1 @@ +- Add X.509 authentication diff --git a/base_external_dbsource_sqlite/readme/USAGE.md b/base_external_dbsource_sqlite/readme/USAGE.md new file mode 100644 index 00000000..8e53180a --- /dev/null +++ b/base_external_dbsource_sqlite/readme/USAGE.md @@ -0,0 +1,8 @@ +To use this module: + +- Go to Settings \> Database Structure \> Database Sources +- Click on Create to enter the following information: +- Datasource name  +- Pasword +- Connector: Choose the database to which you want to connect +- Connection string: Specify how to connect to database diff --git a/base_external_dbsource_sqlite/static/description/icon.png b/base_external_dbsource_sqlite/static/description/icon.png new file mode 100644 index 00000000..3a0328b5 Binary files /dev/null and b/base_external_dbsource_sqlite/static/description/icon.png differ diff --git a/base_external_dbsource_sqlite/static/description/index.html b/base_external_dbsource_sqlite/static/description/index.html new file mode 100644 index 00000000..2da2d1af --- /dev/null +++ b/base_external_dbsource_sqlite/static/description/index.html @@ -0,0 +1,472 @@ + + + + + +External Database Source - SQLite + + + +
+

External Database Source - SQLite

+ + +

Beta License: LGPL-3 OCA/server-backend Translate me on Weblate Try me on Runboat

+

This module extends base_external_dbsource, allowing you to connect +to foreign SQLite databases using SQLAlchemy.

+

Table of contents

+ +
+

Installation

+

To install this module, you need to:

+
    +
  • Install sqlalchemy python library
  • +
+
+
+

Configuration

+

To configure this module, you need to:

+
    +
  1. Database sources can be configured in Settings > Configuration -> +Data sources.
  2. +
+
+
+

Usage

+

To use this module:

+
    +
  • Go to Settings > Database Structure > Database Sources
  • +
  • Click on Create to enter the following information:
  • +
  • Datasource name
  • +
  • Pasword
  • +
  • Connector: Choose the database to which you want to connect
  • +
  • Connection string: Specify how to connect to database
  • +
+
+
+

Known issues / Roadmap

+
    +
  • Add X.509 authentication
  • +
+
+
+

Bug Tracker

+

Bugs are tracked on GitHub Issues. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us to smash it by providing a detailed and welcomed +feedback.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • Daniel Reis
  • +
  • LasLabs
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+ +Odoo Community Association + +

OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use.

+

Current maintainer:

+

anddago78

+

This module is part of the OCA/server-backend project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/base_external_dbsource_sqlite/tests/__init__.py b/base_external_dbsource_sqlite/tests/__init__.py new file mode 100644 index 00000000..87aa84b3 --- /dev/null +++ b/base_external_dbsource_sqlite/tests/__init__.py @@ -0,0 +1 @@ +from . import test_base_external_dbsource diff --git a/base_external_dbsource_sqlite/tests/test_base_external_dbsource.py b/base_external_dbsource_sqlite/tests/test_base_external_dbsource.py new file mode 100644 index 00000000..67fbaf99 --- /dev/null +++ b/base_external_dbsource_sqlite/tests/test_base_external_dbsource.py @@ -0,0 +1,49 @@ +# Copyright 2016 LasLabs Inc. + +from unittest import mock + +from odoo.tests import common + +ADAPTER = ( + "odoo.addons.base_external_dbsource_sqlite.models" + ".base_external_dbsource.sqlalchemy" +) + + +class TestBaseExternalDbsource(common.TransactionCase): + @classmethod + def setUpClass(cls): + super().setUpClass() + cls.dbsource = cls.env.ref("base_external_dbsource_sqlite.demo_sqlite") + + def test_connection_close_sqlite(self): + """It should close the connection""" + connection = mock.MagicMock() + res = self.dbsource.connection_close_sqlite(connection) + self.assertEqual(res, connection.close()) + + def test_connection_open_sqlite(self): + """It should call SQLAlchemy open""" + with mock.patch.object( + type(self.dbsource), "_connection_open_sqlalchemy" + ) as parent_method: + self.dbsource.connection_open_sqlite() + parent_method.assert_called_once_with() + + def test_excecute_sqlite(self): + """It should pass args to SQLAlchemy execute""" + expect = "sqlquery", "sqlparams", "metadata" + with mock.patch.object( + type(self.dbsource), "_execute_sqlalchemy" + ) as parent_method: + self.dbsource.execute_sqlite(*expect) + parent_method.assert_called_once_with(*expect) + + def test_execute_sqlit_without_sqlparams(self): + """It should pass args to SQLAlchemy execute""" + expect = "sqlquery", None, "metadata" + with mock.patch.object( + type(self.dbsource), "_execute_sqlalchemy" + ) as parent_method: + self.dbsource.execute_sqlite(*expect) + parent_method.assert_called_once_with(*expect) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..867daed4 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +# generated from manifests external_dependencies +sqlalchemy