File: api.rst

package info (click to toggle)
postgresql-multicorn 1.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,244 kB
  • sloc: ansic: 3,324; python: 2,258; sql: 751; makefile: 259; sh: 81
file content (99 lines) | stat: -rw-r--r-- 2,188 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
***
API
***

The API is split into two modules: the ``multicorn`` module and the
`utils` module:

  - The ``multicorn`` module contains the whole API needed for implementing
    a Foreign Data Wrapper.
  - The ``utils`` module contains logging and error reporting functions,
    which are ultimately implemented as calls to the PostgreSQL API.


Implementing an FDW
===================

Implementing an FDW is as simple as implementing the
:py:class:`~multicorn.ForeignDataWrapper` class.



Required API
------------

.. py:currentmodule:: multicorn.ForeignDataWrapper

This subset of the API allows your ForeignDataWrapper to be used for read-only
queries.

You have to implement the following methods:

  - :py:meth:`__init__`
  - :py:meth:`execute`

.. note:: In the documentation, FDWs implementing this API will be marked with:

          .. api_compat:: :read:


Write API
---------

To implement full write capabilites, the following property must be implemented:


.. autoattribute:: multicorn.ForeignDataWrapper.rowid_column

In addition to that, you should implement each DML operation as you see fit:

  - :py:meth:`insert`
  - :py:meth:`update`
  - :py:meth:`delete`



.. note:: In the documentation, FDWs implementing this API will be marked with:

          .. api_compat::
            :write:

Transactional API
-----------------

Transactional Capabilities can be implemented with the following methods:


.. automethod:: multicorn.ForeignDataWrapper.begin
.. automethod:: multicorn.ForeignDataWrapper.pre_commit
.. automethod:: multicorn.ForeignDataWrapper.rollback
.. automethod:: multicorn.ForeignDataWrapper.sub_begin
.. automethod:: multicorn.ForeignDataWrapper.sub_commit
.. automethod:: multicorn.ForeignDataWrapper.sub_rollback

.. note:: In the documentation, FDWs implementing this API will be marked with:

          .. api_compat::
            :transaction:


Full API
========

.. autoclass:: multicorn.ForeignDataWrapper
   :special-members: __init__
   :members:


.. autoclass:: multicorn.SortKey

.. autoclass:: multicorn.Qual
   :members:

.. autoclass:: multicorn.ColumnDefinition
   :members:

.. autoclass:: multicorn.TableDefinition
   :members: