Closed jeffarrubla closed 1 year ago
Solution:
from pypika.functions import Function
class parse_json(Function):
def __init__(self, *terms, **kwargs):
super(parse_json, self).__init__("parse_json", *terms, **kwargs)
Query.into("my_table")
.columns(
"col_1",
"col_2"
)
.from_(
Query.select(
Parameter(":1"),
Parameter(":2"),
)
)
.select(
"$1",
parse_json("$2"),
)
.get_sql(quote_char=None)
.replace("'", "") # A hack for removing the ' in the parse_json parameter
Hello,
so I'm trying to do the next query, using parse_json, into pypika
INSERT INTO my_table(col_1, col_2) SELECT $1,parse_json($2) FROM VALUES(:1, :2)
I have:
But I get:
INSERT INTO my_table (col_1,col_2) VALUES (:1,:2)
So i was wondering how can I do a
insert into
usingselect from values
Thanks in advance!