Exemple #1
0
    def _transmit(self, formatted_item, subscriber, output_channel):
        """ Transmit the given formatted item to the configured ODBC output, configuration consists of the connection
         string and the name of a stored procedure
        :param formatted_item:
        :param subscriber:
        :param output_channel:
        :return:
        """
        if not superdesk.app.config['ODBC_PUBLISH'] or not pyodbc_available:
            raise PublishODBCError()

        config = output_channel.get('config', {})

        try:
            with pyodbc.connect(config['connection_string']) as conn:
                item = formatted_item['formatted_item']

                q_item = get_resource_service('publish_queue').find_one(req=None,
                                                                        formatted_item_id=formatted_item['_id'])
                item['publish_date'] = q_item['_created'].replace(tzinfo=utc).astimezone(tz=None).strftime(
                    '%Y-%m-%d %H:%M:%S.%f')[:-3]

                ret = self._CallStoredProc(conn, procName=config['stored_procedure'], paramDict=item)
                conn.commit()
            return ret
        except Exception as ex:
            raise PublishODBCError.odbcError(ex, output_channel)
Exemple #2
0
    def _transmit(self, queue_item, subscriber):
        """
        Transmit the given formatted item to the configured ODBC output. Configuration must have connection string
        and the name of a stored procedure.
        """

        if not superdesk.app.config['ODBC_PUBLISH'] or not pyodbc_available:
            raise PublishODBCError()

        config = queue_item.get('destination', {}).get('config', {})

        try:
            with pyodbc.connect(config['connection_string']) as conn:
                item = json.loads(queue_item['formatted_item'])

                ret = self._CallStoredProc(conn,
                                           procName=config['stored_procedure'],
                                           paramDict=item)
                conn.commit()
            return ret
        except Exception as ex:
            raise PublishODBCError.odbcError(ex, config)
Exemple #3
0
    def _transmit(self, queue_item, subscriber):
        """
        Transmit the given formatted item to the configured ODBC output. Configuration must have connection string
        and the name of a stored procedure.
        """

        if not superdesk.app.config['ODBC_PUBLISH'] or not pyodbc_available:
            raise PublishODBCError()

        config = queue_item.get('destination', {}).get('config', {})

        try:
            with pyodbc.connect(config['connection_string']) as conn:
                item = json.loads(queue_item['formatted_item'])

                ret = self._CallStoredProc(conn, procName=config['stored_procedure'], paramDict=item)
                conn.commit()
            return ret
        except Exception as ex:
            raise PublishODBCError.odbcError(ex, config)
Exemple #4
0
# at https://www.sourcefabric.org/superdesk/license

from superdesk.publish import register_transmitter
from superdesk.publish.publish_service import PublishService
from superdesk.errors import PublishODBCError
import superdesk
import json

try:
    import pyodbc

    pyodbc_available = True
except ImportError:
    pyodbc_available = False

errors = [PublishODBCError.odbcError().get_error_description()]


class ODBCPublishService(PublishService):
    """
    ODBCPublishService
    """

    def _transmit(self, queue_item, subscriber):
        """
        Transmit the given formatted item to the configured ODBC output. Configuration must have connection string
        and the name of a stored procedure.
        """

        if not superdesk.app.config['ODBC_PUBLISH'] or not pyodbc_available:
            raise PublishODBCError()
Exemple #5
0
import json
import superdesk

from superdesk.publish import register_transmitter
from superdesk.publish.publish_service import PublishService
from superdesk.errors import PublishODBCError

try:
    import pyodbc

    pyodbc_available = True
except ImportError:
    pyodbc_available = False

errors = [PublishODBCError.odbcError().get_error_description()]


class ODBCPublishService(PublishService):
    """Superdesk ODBC transmitter.

    Calls a stored procedure with item data.

    :param string connection_string:
    :param string stored_procedure:
    """

    NAME = "ODBC"

    def _transmit(self, queue_item, subscriber):
        """