I want to develop a IoT application using Python that runs on ships and sends data occasionally when a network connection is available. This is the case in about 10% of the time.
Is there any pattern / implementation available who handles exactly this use case? I already read about MQTT and RabbitMQ/AMQP but the implementations expect that the client reaches the broker at the time of sending the message. What I need is some type of local persistance that builds up a local queue and sends the messages when a connection is detected. 
I know that I could handle that for myself and us a SQLite DB but I think that this is no rare use case so I am sure there must be a solution for this and I just used the wrong search terms.
The pattern you're looking for is already implemented in the standard PAHO MQTT Client, as part of the Quality Of Service (QOS) flow.
All you need to do, is to call the method 'publish' with the parameter 'qos' being equal to 2. The framework will take care of everything else for you, and automatically buffer the messages till a connection is available.
There are 2 points to notice however:
- the buffer is an in-memory buffer, that is in a case of a power outage, all messages will be lost. If the messages cannot be lost in such a scenario, you have to implement persistent storage of messages into a local file / database.

As an in-memory buffer it is limited by the total available memory for your python code. So for very large number of messages or message size, possibly exceeding available memory, you would also have to implement persistent local storage.
Pattern for handling message delivery in IoT applications when not online 24/7