MCPcopy
hub / github.com/psycopg/psycopg / make_schema

Method make_schema

tests/fix_faker.py:249–263  ·  view source on GitHub ↗

Create a schema spec from a Python type. A schema specifies what Postgres type to generate when a Python type maps to more than one (e.g. tuple -> composite, list -> array[], datetime -> timestamp[tz]). A schema for a type is represented by a tuple (type, ...) which

(self, cls: type)

Source from the content-addressed store, hash-verified

247 return rv
248
249 def make_schema(self, cls: type) -> tuple[type, ...] | type | None:
250 """Create a schema spec from a Python type.
251
252 A schema specifies what Postgres type to generate when a Python type
253 maps to more than one (e.g. tuple -> composite, list -> array[],
254 datetime -> timestamp[tz]).
255
256 A schema for a type is represented by a tuple (type, ...) which the
257 matching make_*() method can interpret, or just type if the type
258 doesn't require further specification.
259
260 A `None` means that the type is not supported.
261 """
262 meth = self._get_method("schema", cls)
263 return meth(cls) if meth else cls
264
265 def get_maker(self, spec):
266 cls = spec if isinstance(spec, type) else spec[0]

Callers 2

choose_schemaMethod · 0.95
schema_listMethod · 0.95

Calls 1

_get_methodMethod · 0.95

Tested by

no test coverage detected