Cannot change data source for injected sql

I am using pycharm professional, 2019.1.2 preview.

Most of the time the database I deal with is snowflake.  Sometimes, however, it is MS SQL Server.

Here's my problem: when defining a sql command as a python variable, it injects the SQL language but it thinks it is snowflake.  And it seems there is no way to tell it that this is actually intended for sql server.  The sql highlighting is highlighting syntax errors and missing tables; but these are all false because the dialect and data source wrong.

Is there any way to fix this?



Comment actions Permalink


Check your configuration under **File | Settings | Languages & Frameworks | SQL Dialects**

Also, note that you can change the dialect from the editor, using Alt+Enter menu:


If you already tried that and it doesn't work, please provide your code sample which can be used to reproduce the issue.

Comment actions Permalink

It does not give me the option to change dialect:

Ok -- after changing in setting > languages > sql dialects, i am able to change.   

But this is a very cumbersome way to do this.  The inability to change with alt+enter, is this a bug in 2019.1.2 preview?

I have my global / project dialects set to snowflake, because that's what I use mostly.  But I'd like to be able to switch for a particular file, or even a particular string within a file.


Comment actions Permalink

Do you have 2019.1.1 installed to test? I can't reproduce it on 2019.1.1

I'll try on 2019.1.2 and will let you know if I can reproduce it.

Comment actions Permalink

Tested on 2019.1.2 Preview, but also can't reproduce.

Ensure that SQL dialect detection is enabled in the settings:



Comment actions Permalink

Ok I figured it out.  The problem is as follows.

Under Languages & Frameworks > SQL Dialects, if you have a global dialect set, it no longer gives the option to switch dialect with Alt+Enter.

If I unset global dialect, the option returns.

I had global dialect set to snowflake, in this case.

This should not be the case, correct?  We should still be able to change dialect, even if we have a global dialect set?

The same issue presents with project dialect.  That is, you can set project dialect and global dialect, and they both disable dialect switching from alt+enter.

My assumption was that the global / project settings would be like defaults that could be overridden for specific files.

Comment actions Permalink

You are right, it seems that selecting global or project dialect indeed hides that option from the menu, apparently this is intended behavior.

Sorry for not coming to that conclusion right away, I was under the same impression as you, but apparently we were wrong.


Please sign in to leave a comment.