DBeaver “格式化”-->“格式化 SQL”-->“转换为大写”适用于所有单词。如何仅格式化系统保留的 SQL 命令单词?

DBeaver “格式化”-->“格式化 SQL”-->“转换为大写”适用于所有单词。如何仅格式化系统保留的 SQL 命令单词?

当我右键单击选定的 SQL 查询并选择“格式化 SQL”时,它会将 SQL 更改为小写。

另一个命令“转换为大写”不是 SQL 智能的,这意味着它会将选择中的所有内容更改为大写,因此它也不会在名称中使用“SQL”。

在此处输入图片描述

查询本身不区分大小写,并在 SQL 中通过全局更改为大写或小写来运行,但是使用 SQL 查询结果的外部 Python 函数在将其变为大写时无法再找到所需的列,因为它会搜索小写的 column_name。

这导致我的前端出现以下错误:


AttributeError

AttributeError: 'Source' object has no attribute 'schedule_day'
Traceback (most recent call last)

    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1836, in __call__

    return self.wsgi_app(environ, start_response)

    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1820, in wsgi_app

    response = self.make_response(self.handle_exception(e))

    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1403, in handle_exception

    reraise(exc_type, exc_value, tb)

    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app

    response = self.full_dispatch_request()

    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request

    rv = self.handle_user_exception(e)

    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception

    reraise(exc_type, exc_value, tb)

    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request

    rv = self.dispatch_request()

    File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request

    return self.view_functions[rule.endpoint](**req.view_args)

    File "/monitoring/app.py", line 149, in show_broken_sources

    if source.schedule_day is None:

    AttributeError: 'Source' object has no attribute 'item_day'

The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.

To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

    dump() shows all variables in the frame
    dump(obj) dumps all that's known about the object

Brought to you by DON'T PANIC, your friendly Werkzeug powered traceback interpreter.

有没有办法将其更改为大写仅适用于 SQL 命令字,最好是默认的?

答案1

转到文件 --> 属性 --> 编辑器 --> SQL 编辑器 --> 格式化。您甚至可以选择数据源的设置、全局设置或外部设置。

在此处输入图片描述

在我的例子中,在“默认格式化程序”中选择“上部”,然后您可以使用此格式化程序Ctrl+ Shift+F

相关内容