本文介绍了Psycopg2不喜欢以小写字母开头的表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Windows XP下运行ActiveState的ActivePython 2.6.5.12和PostgreSQL 9.0 Beta 1。

I am running ActiveState's ActivePython 2.6.5.12 and PostgreSQL 9.0 Beta 1 under Windows XP.

如果我创建的表带有大写首字母(即Books) ,当我运行select语句时,psycopg2返回编程错误:关系 books不存在错误消息: execute( SELECT * FROM Books)。如果运行以下命令,将返回相同的错误: execute( SELECT * FROM books)。但是,如果我将表更改为小写的名字(即书籍),则以上两种语句中的任何一种都可以。

If I create a table with an upper case first letter (i.e. Books), psycopg2 returns the "Programming Error: relation "books" does not exist" error message when I run the select statement: execute("SELECT * FROM Books"). The same error is returned if I run: execute("SELECT * FROM books"). However, if I change the table to a lower case first name (i.e. books), then either of the above statements works.

表名应该是小写吗?名字?这是设置,功能还是错误?我是否缺少明显的东西?

Are tables name supposed to have a lower case first name? Is this a setting or a feature or a bug? Am I missing something obvious?

推荐答案

阅读,尤其是有关带引号的标识符的部分。

Read "Identifiers and Key Words" from the manual, especially the part about "quoted identifiers".

这篇关于Psycopg2不喜欢以小写字母开头的表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 08:15