[英](psycopg2.errors.UndefinedColumn) column "name" does not exist
我在“NAME”上使用了双引号以使其区分大小写,但它仍然不起作用。 我收到一条错误消息,指出“名称”列不存在。
(我使用 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)
我收到错误:
* 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...
^
我还注意到,当我使用 cell magic %%sql
时,带双引号的列名有效,但当我使用单行 magic %sql
时出现错误
使用单行魔术命令%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)
此代码有效
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.