Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

How to create .sql as and output file

Lumjing
8 - Asteroid

I have a excel table as below. I want to output the table below with "SQL Query" column as .sql. can you please help how to achieve this

 

Input

CodeSQL Query
123SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;

 

I am doing a output file as "123.sql"

when I open the "123.sql" file I am getting the column heading and the codes are inside a " " like below. How can I get "123.sql" file without the "SQL Query" and without the Quotes " "

 

SQL Query
"SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;"
11 REPLIES 11
Lumjing
8 - Asteroid

@jdminton @PhilipMannering thank you for all the help. I am having a "SQL Query" column with one line item like below "Customers.CustomerID;" is also in one line. With the help you provided I was able to generate the ".SQL" file without the " ", but when I open the ".SQL" file it is coming out as one line code. I want the SQL codes to be formatted in sql format. This we are able to achieve using a python "import urllib from sql_formatter.core import format_sql" package and using the code "lambda x: format_sql(x)". But I am not sure how I can implement this in Alteryx using the Python tool. do you have any suggestions?

 

CodeSQL Query
123SELECT Orders.OrderID, Customers.CustomerName FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
apathetichell
18 - Pollux

Hey - You're talking about that python package as though it's a standardized format. It's not. It has 32 stars which isn't huge in Python-land and the latest version was released close to 3 years ago. I get that you like it - it's cool. but to get it to match exactly, I'd recommend building it yourself - or using that specific python package in the python tool.

 

 

Labels