Debian Codegraph @

rdflib_sqlalchemy/types.py

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 from rdflib.graph import Graph, QuotedGraph
2 from rdflib.term import Node
•3 text_type = str
4 from sqlalchemy import types
5
6
7 class TermType(types.TypeDecorator):
8 """Term typology."""
9
10 impl = types.Text()
11 cache_ok = True
12
13 def process_bind_param(self, value, dialect):
14 """Process bound parameters."""
15 if isinstance(value, (QuotedGraph, Graph)):
16 return text_type(value.identifier)
17 elif isinstance(value, Node):
18 return text_type(value)
19 else:
20 return value