[英](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...
^
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
时出现错误
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.