V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Outliver0
V2EX  ›  程序员

[postgresql] 表查询错误 psycopg2.errors.UndefinedTable

  •  
  •   Outliver0 · 2021-08-12 23:27:42 +08:00 · 936 次点击
    这是一个创建于 993 天前的主题,其中的信息可能已经有所发展或是发生改变。

    1.png 如上图,因为数据表创建时表名有大写字母,所以查询的时候加双引号,我试过不加双引号、加单引号、加反引号等各种方法,报的错都是同一个,网上的解决方案也都加双引号解决,来问问有遇到过相似情况的没,帮忙解决一下;

    -- Table: Infos.User_Info
    
    -- DROP TABLE "Infos"."User_Info";
    
    CREATE TABLE "Infos"."User_Info"
    (
        id integer NOT NULL,
        name "char",
        age integer,
        CONSTRAINT "User_Info_pkey" PRIMARY KEY (id)
    )
    
    TABLESPACE pg_default;
    
    ALTER TABLE "Infos"."User_Info"
        OWNER to postgres;
    

    使用的时 python 的 psycopg2,python 版本 3.9.4

    3 条回复    2021-08-13 17:59:01 +08:00
    Outliver0
        1
    Outliver0  
    OP
       2021-08-13 08:59:26 +08:00
    dd
    777777
        2
    777777  
       2021-08-13 11:21:59 +08:00
    create table "user_info"。为什么创建表要有一个点呢?不是直接命名表名?
    Outliver0
        3
    Outliver0  
    OP
       2021-08-13 17:59:01 +08:00
    @777777 指定了 Schemas
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   994 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 23:29 · PVG 07:29 · LAX 16:29 · JFK 19:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.