简体   繁体   English

(psycopg2.errors.UndefinedColumn) 列“名称”不存在

[英](psycopg2.errors.UndefinedColumn) column "name" does not exist

I used double quotes on "NAME" to make it case sensitive but it still doesn't work.我在“NAME”上使用了双引号以使其区分大小写,但它仍然不起作用。 I get an error saying that the column "name" doesn't exist.我收到一条错误消息,指出“名称”列不存在。

(i use jupyter notebook and sql magic commands) (我使用 jupyter notebook 和 sql 魔术命令)

ppg = [[],[]]
for x in overall_ppg_leaders:
    reg_ppg = %sql SELECT * FROM "rg_player_stats" WHERE "NAME" = :x;
    po_ppg = %sql SELECT * FROM "po_player_stats" WHERE "NAME" = :x;
    ppg[0].append(reg_ppg)
    ppg[1].append(po_ppg)
print(ppg)

I get error:我收到错误:

* postgresql+psycopg2://postgres:***@localhost/NBA_2021-22
(psycopg2.errors.UndefinedColumn) column "name" does not exist
LINE 1: SELECT * FROM rg_player_stats WHERE NAME = 'Kevin Durant';
                                            ^

[SQL: SELECT * FROM rg_player_stats WHERE NAME = %(x)s;]
[parameters: {'x': 'Kevin Durant'}]
(Background on this error at: https://sqlalche.me/e/14/f405)
 * postgresql+psycopg2://postgres:***@localhost/NBA_2021-22
(psycopg2.errors.UndefinedColumn) column "name" does not exist
LINE 1: SELECT * FROM po_player_stats WHERE NAME = 'Kevin Durant';
                                            ^

[SQL: SELECT * FROM po_player_stats WHERE NAME = %(x)s;]
[parameters: {'x': 'Kevin Durant'}]
(Background on this error at: https://sqlalche.me/e/14/f405)
 * postgresql+psycopg2://postgres:***@localhost/NBA_2021-22
(psycopg2.errors.UndefinedColumn) column "name" does not exist
LINE 1: SELECT * FROM rg_player_stats WHERE NAME = 'Donovan Mitchell...
                                            ^

sql表

I also noticed that column name with double quotes works when I use cell magic %%sql but gives me an error when I use the single line magic %sql我还注意到,当我使用 cell magic %%sql时,带双引号的列名有效,但当我使用单行 magic %sql时出现错误

This code works fine此代码工作正常在此处输入图像描述

This code gives me an error这段代码给我一个错误在此处输入图像描述

When using single line magic command %sql , use "\"NAME\"" instead of "NAME" so that it is case sensitive.使用单行魔术命令%sql时,请使用"\"NAME\""而不是 "NAME",以便它区分大小写。

ppg = [[],[]]
for x in overall_ppg_leaders:
    reg_ppg = %sql SELECT "\"PPG\"" FROM "rg_player_stats" WHERE "\"NAME\"" = :x;
    po_ppg = %sql SELECT "\"PPG\"" FROM "po_player_stats" WHERE "\"NAME\"" = :x;
    ppg[0].append(reg_ppg)
    ppg[1].append(po_ppg)
print(ppg)

This code WORKS此代码有效

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 psycopg2.errors.UndefinedColumn:列 - psycopg2.errors.UndefinedColumn: column Django:psycopg2.errors.UndefinedColumn:“pages_page”关系的“page_image”列不存在 - Django: psycopg2.errors.UndefinedColumn: column “page_image” of “pages_page” relation does not exist ProgrammingError:(psycopg2.errors.UndefinedColumn)关系“task_fail”的列“execution_date”不存在 - ProgrammingError: (psycopg2.errors.UndefinedColumn) column "execution_date" of relation "task_fail" does not exist ProgrammingError: (psycopg2.errors.UndefinedColumn),同时使用 sqlalchemy - ProgrammingError: (psycopg2.errors.UndefinedColumn), while working with sqlalchemy psycopg2 - UndefinedColumn:关系的列“日期时间”“<table_name> “ 不存在</table_name> - psycopg2 - UndefinedColumn: column "datetime" of relation "<table_name>" does not exist Psycopg2.errors.Undifinedcolumn:列不存在 - Psycopg2.errors.Undifinedcolumn : column does not exist psycopg2.ProgrammingError:“您的姓名”列不存在 - psycopg2.ProgrammingError: column “your name” does not exist psycopg2.errors.UndefinedTable:关系“练习”不存在 - Django 测试 - psycopg2.errors.UndefinedTable: relation “exercises” does not exist - Django Testing psycopg2.errors.UndefinedTable:关系不存在(连接表) - psycopg2.errors.UndefinedTable: relation does not exist (join table) “psycopg2.errors.UndefinedTable:关系“航班”不存在” - "psycopg2.errors.UndefinedTable: relation "flights" does not exist"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM