Writing custom mount handlers

To mount a custom database into your Splitgraph engine, you have to do three things:

  • Install the foreign data wrapper into the engine (either using PGXN or compiling the wrapper by yourself)
  • Write a Python class deriving from ForeignDataWrapperDataSource that defines the FDW's class and how command line options map to the FDW's own options. For an example, see PostgreSQLDataSource in splitgraph.hooks.data_source.
  • Register the handler in your .sgconfig file:
[data_sources]
handler_name=your.handler.module.HandlerClass

Registering the handler in such a way will also use make it available in the sgr client as an sgr mount subcommand, as well as make it available to be used in Splitfiles.

For an end-to-end example of a custom mount handler querying the Firebase Hacker News API, see Splitgraph's GitHub repository.