Пример #1
0
    def query_db(self):
        if self.conn is not None:
            self.conn.autocommit = True
            install_trigger_function(self.conn)
            install_trigger(self.conn, self.table_name)
            register_event_channel(self.conn)
            try:
                print("LIStening for event...")
                while True:
                    row_ids = []
                    for evt in poll(self.conn):
                        print('New Event: {}'.format(evt))
                        row_id = vars(evt)['row_id']
                        row_ids.append(row_id)

                    if len(row_ids) > 0:
                        self.row_id = max(row_ids)

                        self.query_db_basic()
                        self.transform_and_scale()
                        if self.img is not None:
                            self.send(text_data=self.img.decode('utf-8'))
            except KeyboardInterrupt:
                print('User exit via Ctrl-C; Shutting down...')
                unregister_event_channel(connection)
                uninstall_trigger(connection, table_name)
                uninstall_trigger_function(connection)
                print('Shutdown complete.')
Пример #2
0
    def test_add_public_schema_trigger(self, connection):
        trigger_installed = False

        trigger.install_trigger(connection, "settings")

        try:
            statement = """
            SELECT
                *
            FROM
                information_schema.triggers
            WHERE
                event_object_schema = 'public' AND
                event_object_table = 'settings';
            """
            result = execute(connection, statement)
            if result:
                trigger_installed = True
        except:  # noqa: E722
            # Ignore error, its only use in this test is cause following
            # assertion to fail
            pass

        assert trigger_installed
    def test_add_custom_schema_trigger(self, connection):
        trigger_installed = False

        install_trigger(connection, 'orders', schema='pointofsale')

        try:
            statement = """
            SELECT
                *
            FROM
                information_schema.triggers
            WHERE
                event_object_schema = 'pointofsale' AND
                event_object_table = 'orders';
            """
            result = execute(connection, statement)
            if result:
                trigger_installed = True
        except:
            # Ignore error, its only use in this test is cause following
            # assertion to fail
            pass

        assert (trigger_installed == True)
Пример #4
0
def triggers_installed(connection):
    install_trigger_function(connection, rowid='id')
    install_trigger(connection, 'settings')
    install_trigger(connection, 'orders', schema='pointofsale')
Пример #5
0
def custom_schema_trigger_installed(connection):
    trigger.install_trigger(connection, "orders", schema="pointofsale")
Пример #6
0
def public_schema_trigger_installed(connection):
    trigger.install_trigger(connection, "settings")
Пример #7
0
def triggers_installed(connection):
    install_trigger_function(connection)
    install_trigger(connection, "settings")
    install_trigger(connection, "orders", schema="pointofsale")
def custom_schema_trigger_installed(connection):
    install_trigger(connection, 'orders', schema='pointofsale')
def public_schema_trigger_installed(connection):
    install_trigger(connection, 'settings')