Yes. But to do so, you need to invoke a feature that I am willing to bet only 1% of the 1% knows about.
dataProvider, you can disable groups of functionality. In your case you want to disable
For completeness, I'm showing a few examples. All in your
Disable everything on your dataProvider except methods
But to make things easier, there are "method groups" you can disable. To disable publishing entirely for your dataProvider, do this:
For more information of this forgotten feature from the past, see: The dataProvider Element
If I recall correctly (it's been a very long while since I used this), Sitecore will not throw exceptions or anything when these disabled calls are invoked; rather just silently ignore them and move on.
Edited to add
So I did a bit of investigation. Sitecore has updated the flexibility around this a bit more, so it is possible that this method will be easier for you.
If you look in
App_Config/Sitecore.config for how the
<database id="web"> is wired up, you will see an example of this. It states:
<dataProvider ref="dataProviders/main" param1="$(id)">
<sc.include file="/App_Config/Prefetch/Common.config" />
<sc.include file="/App_Config/Prefetch/Webdb.config" />
Notice how it maps in the "main" data provider, and then tells it to
publishing. This is why the system doesn't break when you do a publish via the UI when you've switched to the "web" database - it simply gets ignored.
So you can either disable this group for your dataProvider entirely, or you can optionally disable it per-database for your provider.
If I recall correctly (as can be seen in a modern day
Sitecore.config) you can also just remove sections from this part of the configuration.
<publishing> element should have the same effect as the above, which removes group