SQL syntax hightlighting

This provides syntax highlighting and auto-completion of SQL in VS Code.

Would it be possible to have a section in a .jl file that VS Code treats as SQL
(for syntax highlight and autocompletion) ? Then convert the result to a Julia DataFrame.
Something like

@SQL_Block  my_connection_string

select * from my_table

end   |> DataFrame

Typically, you’d use a string macro for this, which already gives you the correct syntax highlighting:
image

I’m not sure if you get the auto completions provided by the SQL Server extension, but I highly doubt it. This is not something we can implement on our end.

6 Likes

For the last part of your question, you might look into GitHub - wookay/Octo.jl: Octo.jl 🐙 is an SQL Query DSL in Julia

Thanks I wasn’t aware of SQL" "

This initially gives error @sql_str not defined .

Adding macro sql_str(x) x end makes it work but I lose the ability to put $variables in the string.

Is there a way to use $variables within a sql"“” “”" string ?

I’d recommend using something like GitHub - JuliaComputing/SQLStrings.jl: Safe interpolations for SQL query strings instead.

It is also worth looking at FunSQL.jl