Disable SQL detection in JetBrains PyCharm

2019-04-20 08:02发布

I was trying to type the following line:

self._label = QtGui.QLabel("Select parameter from selected category")

And PyCharm decided I was doing an SQL Query or something and gave errors about having no data connections configured. The Syntax Highlighting within the string changed and Select and from became highlighted like keywords. Since I don't use SQL or any database whatnot at all (I'm an engineer who programs - I don't use databases, sorry) ... I simply disabled the SQL Plugin in the PyCharm plugin settings.

Is there a less drastic way to disable this auto-inspection behavior in case I ever wanted that plugin turned on? It seems drastic that any time it sees Select x from y in a string it thinks it's an SQL query. I tried disabling all the SQL inspections under the Inspections settings.

Thanks for any help.

4条回答
Explosion°爆炸
2楼-- · 2019-04-20 08:27

I am using PhpStorm and I have managed to stop it complaining by right-clicking the error square in the top right then ...

Right click Square > Customize highlighting level > Configure Inspections >

Scroll down to Sql and expand the tree

Uncheck "No Data Sources congirued"

Although you may consider this drastic its the only way, JetBains IDEs are professional tools which have been in development a while, because of the many different requirements of its users it has many options and features.

The settings menu is very clever, you can click

File > Settings > {Then start typing in search : SQL }

Then you can already see the SQL Inspection options including the ones that you want to disable.

When you get used to your IDE of choice, you will be fine

查看更多
淡お忘
3楼-- · 2019-04-20 08:27

You can change it in Preferences> Editor> Inspection (⌘-comma for Mac user) Here is the snapshot

查看更多
Root(大扎)
4楼-- · 2019-04-20 08:40

To turn off SQL injections go to Settings | Editor | Language injections and turn off anything related to SQL.

enter image description here

查看更多
小情绪 Triste *
5楼-- · 2019-04-20 08:49

The message:

No data sources are configured to run this SQL and provide advanced code assistance.`

is a little explicit and IMHO a little unnecessary, because I really think that I don't need to configure a database for every project which we have some SQL queries.

To handle with this message, you have two options:

  1. Configure a Data Source to your project, using the ALT + ENTER above the message and using the option Configure a Data Source: Add a data source

or

  1. Disable this SQL dialect detection inspection on the Inspection options on the IDE settings:

    Disable the SQL dialect detection

The second option is the best approach for me, unless we really want or need a Data Source on your project.

查看更多
登录 后发表回答