Hi all,
Pretty new to this forum and switch and i was wondering if I could pick your brains.
Currently I have a flow that writes to a csv file from my sql database. I use execute command with an argument that contains select sql statements which then writes one row to my csv file. This then continues to loop until all rows have been created.
My question is, is there a way to write all the rows in one go without having to loop through row by row?
Now i'm not really clued up when it comes to creating scripts, I do however have the scripting module, but i was hoping there was a way to do this without creating a script?
Cheers
SQL to CSV
Re: SQL to CSV
Do you have the database module in Switch? If so, then you can create a CSV file from an SQL query using the "Database connect" tool.
Re: SQL to CSV
Alright Padawan,
Yeh i do have the database module. I am currently using this to update my database once a row has been added. I was just wondering if there is a way to write multiple rows in one go rather than one row at a time? I also have the scripting module too.
Cheers
Yeh i do have the database module. I am currently using this to update my database once a row has been added. I was just wondering if there is a way to write multiple rows in one go rather than one row at a time? I also have the scripting module too.
Cheers
Re: SQL to CSV
Do you want to write from your database to a CSV or from a CSV to your database?
If you want to write from your database to a CSV, then you can use the "Database Connect" element. If you use an SQL statement which will return multiple rows and set the log type to CSV, then you will get a multirow CSV file in the output.
If you want to write from a CSV to a database, multiple rows at the same time, then I think you'll need a script.
If you want to write from your database to a CSV, then you can use the "Database Connect" element. If you use an SQL statement which will return multiple rows and set the log type to CSV, then you will get a multirow CSV file in the output.
If you want to write from a CSV to a database, multiple rows at the same time, then I think you'll need a script.
Re: SQL to CSV
alright padawan,
yeh i want to be able to write from my sql database to csv. i've tried creating a csv log but all i seem to be getting is a red cog on my database connect element which says warning job was started. you seen this before?
cheers
yeh i want to be able to write from my sql database to csv. i've tried creating a csv log but all i seem to be getting is a red cog on my database connect element which says warning job was started. you seen this before?
cheers
Re: SQL to CSV
Me being a plonker, it was my odbc connection not configured properly. Got it working cheers mate.
Re: SQL to CSV
Hi,
Is there a way to delete the first two rows of the log file that comes out? or disable it somehow?
Cheers
Is there a way to delete the first two rows of the log file that comes out? or disable it somehow?
Cheers
Re: SQL to CSV
It's not possible to disable it to my knowledge.
I also don't know an easy way to remove them. Scripting will work of course.
On mac you could build something using one of the tools mentioned on the following page and execute command:
https://stackoverflow.com/questions/245 ... rom-output
There is a big chance you'll need to run your command via an extra bash script in the execute command.
If you are on mac, then maybe I can build a sample when I have some time next week.
I also don't know an easy way to remove them. Scripting will work of course.
On mac you could build something using one of the tools mentioned on the following page and execute command:
https://stackoverflow.com/questions/245 ... rom-output
There is a big chance you'll need to run your command via an extra bash script in the execute command.
If you are on mac, then maybe I can build a sample when I have some time next week.