Jump to content
miguelccarvalho

Paste directly in app (query in Sequel Pro)

Recommended Posts

Hi,

 

I want my workflow to open Sequel Pro and paste a SQL query directly in the query field (and, ideally, run it and export to CSV). 

 

As of now, it opens Sequel Pro and gets the query in the clipboard so that I only have to do CMD-V into Sequel Pro. However, I was wondering if there is a way to automate that last part - paste, run query, and export to CSV (all of which would run from inside Sequel Pro).

 

Is this possible?

 

EDIT: I've created the query in it's own SQL file so workflow now opens that file with Sequel Pro --> CMD-V part is solved. Still missing Run Query + Export as CSV

Edited by miguelccarvalho
Achieved partial solution

Share this post


Link to post

You can simulate ⌘V and ⌘R using AppleScript to paste and run the query:

 

tell application "Sequel Pro"

    activate

    tell application "System Events"

        keystroke "v" using command down

        -- wait 1/5th of a second for the paste to complete

        delay 0.2

        keystroke "r" using command down

    end tell

end tell

Share this post


Link to post

I wasn't able to replicate this and I think it is because Sequel Pro requires me to hit "Connect" before it starts. 

 

Re-formulating the problem, I need something that:

1) Activates Sequel Pro;

2) Hits "Enter" in the "Connect" button which shows upon opening the app;

3) Pastes the query;

4) Runs the query;

5) Exports to CSV

 

I added something to the script and it works :)

 

My keyword is now connected to a Run Script object which contains:

tell application "Sequel Pro"
    activate
    tell application "System Events"
            keystroke return
        keystroke "v" using command down
        -- wait 1/5th of a second for the paste to complete
        delay 0.2
        keystroke "r" using command down
    end tell
end tell

So I'm just missing the export to CSV part as I can't find the keystroke in Sequel Pro for 'Export to CSV'. How can I do that?

 

Thanks a lot!

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...