11 from ctypes
import POINTER
12 from SQLamarr
import clib, c_TransformerPtr
13 from typing
import List, Union
17 clib.new_TemporaryTable.argtypes = (
25 clib.new_TemporaryTable.restype = c_TransformerPtr
28 """Creates a temporary table from an SQL query. Persitency can be enabled.
30 Python binding of `SQLamarr::TemporaryTable`.
38 query: Union[str, List[str]],
39 make_persistent: bool =
False,
42 Acquires the reference to an open connection to the DB and configure the
45 @param db: An open database connection;
46 @param output_table: name of the table where the query output is stored;
47 @param outputs: list of the output column names for further reference;
48 @param query: SQL query (or queries) defining the output columns;
49 @param make_persistent: mark the TABLE as persistent.
51 if isinstance(query, str):
54 self.
_self_self = clib.new_TemporaryTable(
56 output_table.encode(
'ascii'),
57 ";".join(outputs).encode(
'ascii'),
58 ";".join([q.replace(
";",
" ")
for q
in query]).encode(
'ascii'),
63 """@private: Release the bound class instance"""
64 clib.del_Transformer(self.
_self_self)
67 def raw_pointer(self):
68 """@private: Return the raw pointer to the algorithm."""
69 return self.
_self_self
Creates a temporary table from an SQL query.
def __init__(self, SQLite3DB db, str output_table, List[str] outputs, Union[str, List[str]] query, bool make_persistent=False)
Acquires the reference to an open connection to the DB and configure the Transformer.