mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[MIG] base_external_dbsource_sqlite: Migration to v13.0
[UPD] Update base_external_dbsource_sqlite.pot [UPD] README.rst
This commit is contained in:
committed by
Andrea Cattalani
parent
f7251ddd5d
commit
cb88683c9f
@@ -4,23 +4,25 @@
|
||||
|
||||
import logging
|
||||
|
||||
from odoo import api, models
|
||||
from odoo import models
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
try:
|
||||
from odoo.addons.base_external_dbsource.models import (
|
||||
base_external_dbsource,
|
||||
)
|
||||
from odoo.addons.base_external_dbsource.models import base_external_dbsource
|
||||
|
||||
CONNECTORS = base_external_dbsource.BaseExternalDbsource.CONNECTORS
|
||||
try:
|
||||
import sqlalchemy
|
||||
CONNECTORS.append(('sqlite', 'SQLite'))
|
||||
|
||||
CONNECTORS.append(("sqlite", "SQLite"))
|
||||
except ImportError:
|
||||
_logger.info('SQLAlchemy library not available. Please '
|
||||
'install "sqlalchemy" python package.')
|
||||
_logger.info(
|
||||
"SQLAlchemy library not available. Please "
|
||||
'install "sqlalchemy" python package.'
|
||||
)
|
||||
except ImportError:
|
||||
_logger.info('base_external_dbsource Odoo module not found.')
|
||||
_logger.info("base_external_dbsource Odoo module not found.")
|
||||
|
||||
|
||||
class BaseExternalDbsource(models.Model):
|
||||
@@ -28,25 +30,20 @@ class BaseExternalDbsource(models.Model):
|
||||
|
||||
_inherit = "base.external.dbsource"
|
||||
|
||||
PWD_STRING_SQLITE = 'Password=%s;'
|
||||
PWD_STRING_SQLITE = "Password=%s;"
|
||||
|
||||
@api.multi
|
||||
def connection_close_sqlite(self, connection):
|
||||
return connection.close()
|
||||
|
||||
@api.multi
|
||||
def connection_open_sqlite(self):
|
||||
return self._connection_open_sqlalchemy()
|
||||
|
||||
@api.multi
|
||||
def execute_sqlite(self, sqlquery, sqlparams, metadata):
|
||||
return self._execute_sqlalchemy(sqlquery, sqlparams, metadata)
|
||||
|
||||
@api.multi
|
||||
def _connection_open_sqlalchemy(self):
|
||||
return sqlalchemy.create_engine(self.conn_string_full).connect()
|
||||
|
||||
@api.multi
|
||||
def _execute_sqlalchemy(self, sqlquery, sqlparams, metadata):
|
||||
rows, cols = list(), list()
|
||||
for record in self:
|
||||
|
||||
Reference in New Issue
Block a user