推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
solxnp
V2EX  ›  Python

pycharm 中写裸 sql 时,不能识别 fstring 的变量?

  •  
  •   solxnp · May 27, 2019 · 3286 views
    This topic created in 2735 days ago, the information mentioned may be changed or developed.

    有没有用的熟练的大佬知道在哪里可以设置,亦或是这就是个 Bug ?

    如图,说不影响是假的,专门起的给 sql 用的变量,看起来都是灰色未使用,总是忍不住想要删掉。。。

    VZQmDS.png

    VZQnHg.png

    7 replies  •  2019-05-27 17:57:00 +08:00
    neoblackcap
    neoblackcap
    May 27, 2019
    1
    看看这个情况肯定就是两种语法冲突啦,你要 Pycharm 按哪种语法进行高亮?按目前来看,你这个语言不属于 SQL,因此高亮不起来。如果按 f-string 高亮,select 这些 SQL 的关键字也就不可能高亮。
    这东西要能做,完全就是 hack,去 youtrack 提 issue 吧
    daiqiangbudainiu
    daiqiangbudainiu
    May 27, 2019
    2
    你这个逗号有问题吧,写代码用英文输入法,不要用中文输入法的英文
    edsion996
    edsion996
    May 27, 2019
    3
    ![]( )
    为什么我可以?
    solxnp
    solxnp
    OP
    May 27, 2019
    4
    @zjb861107 应该是如 1 楼所说的两种语法冲突了。

    你的可以是因为你没使用 sql 语法,看下我的 sql 截图:

    ![VZNWa6.png]( https://s2.ax1x.com/2019/05/27/VZNWa6.png)
    solxnp
    solxnp
    OP
    May 27, 2019
    5
    @neoblackcap 确实是这个问题!我尝试在 select 后面加个 1,使之不被认为是个 sql 后,就正常了
    solxnp
    solxnp
    OP
    May 27, 2019
    6
    权衡利弊之后,选择了关闭 sql 的语法提示,不然右侧提示全是红杠。

    关闭位置位于 File--Settings--Editor--Language Injections--取消勾选 "SQL select/delete/insert/updatge/create"
    gejun123456
    gejun123456
    May 27, 2019 via iPhone
    7
    写个 idea 插件就能支持了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   852 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:29 · PVG 05:29 · LAX 13:29 · JFK 16:29
    ♥ Do have faith in what you're doing.