Mican Bican | 8 Feb 2005 19:33
Picon

tables with small letters?

Hello,

I write a test python file to connect my postgresql database. My table 
called Testtabelle. Python always bring an error... "a relation called 
testtabelle not exists" or so.. So I try to change the tablename from 
Testtabelle to testtabelle... uups and it works..?? Is this possible 
that pypgsql only allows tablenames with small letters????

thank you

Muhlis

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Karsten Hilbert | 8 Feb 2005 19:46
Picon

Re: tables with small letters?

You should better post on a PostgreSQL-specific list such as
pgsql-general.

> I write a test python file to connect my postgresql database. My table 
> called Testtabelle. Python always bring an error... "a relation called 
> testtabelle not exists" or so.. So I try to change the tablename from 
> Testtabelle to testtabelle... uups and it works..?? Is this possible 
> that pypgsql only allows tablenames with small letters????

The SQL standard says that table names must be case
insensitive. It suggests to fold all names to UPPERCASE.
PostgreSQL acts by the standard and uses table names case
insensitive. However, it folds all names to *lower*case (I
tend to agree that is more readable). So, Testtable,
TESTtable, tesTTable are all testtable as far as PostgreSQL is
concerned.

You *can* make PostgreSQL be case sensitive with table names,
however: just use quotes ("") around the names -- always !

Karsten
--

-- 
GPG key ID E4071346  <at>  wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
(Continue reading)

Gerhard Häring | 8 Feb 2005 19:50
Picon
Gravatar

Re: tables with small letters?

Mican Bican wrote:
> Hello,
> 
> I write a test python file to connect my postgresql database. My table 
> called Testtabelle. Python always bring an error... "a relation called 
> testtabelle not exists" or so.. So I try to change the tablename from 
> Testtabelle to testtabelle... uups and it works..?? Is this possible 
> that pypgsql only allows tablenames with small letters????

pyPgSQL has nothing to do with it. Probably the table was created with 
something like:

create table "Testtabelle"

and then, case does matter I believe. At least I've seen something like 
this recently in Oracle.

-- Gerhard

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
Mican Bican | 8 Feb 2005 20:28
Picon

Re: tables with small letters?

Gerhard Häring schrieb:

> Mican Bican wrote:
>
>> Hello,
>>
>> I write a test python file to connect my postgresql database. My 
>> table called Testtabelle. Python always bring an error... "a relation 
>> called testtabelle not exists" or so.. So I try to change the 
>> tablename from Testtabelle to testtabelle... uups and it works..?? Is 
>> this possible that pypgsql only allows tablenames with small letters????
>
>
> pyPgSQL has nothing to do with it. Probably the table was created with 
> something like:
>
> create table "Testtabelle"
>
> and then, case does matter I believe. At least I've seen something 
> like this recently in Oracle.
>
> -- Gerhard
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
(Continue reading)

Ben Scherrey | 9 Feb 2005 06:36

Re: tables with small letters?

Unfortunately table names that aren't pure lower-case are a bit 
annoying. I converted an app from Access to Postgres and changing the 
code for all the table names wasn't an option. Try changing your select 
statement to: 'select * from "Farbton"' and see if that doesn't work. 
Everywhere you reference a table name you will have to enclose it in "". 
Its up to you to decide which is the bigger pain in the butt to deal 
with, quoting table names or changing them to lower case in the db 
structure.

    good luck,

       Ben Scherrey

Mican Bican wrote:

> Gerhard Häring schrieb:
>
>> Mican Bican wrote:
>>
>>> Hello,
>>>
>>> I write a test python file to connect my postgresql database. My 
>>> table called Testtabelle. Python always bring an error... "a 
>>> relation called testtabelle not exists" or so.. So I try to change 
>>> the tablename from Testtabelle to testtabelle... uups and it 
>>> works..?? Is this possible that pypgsql only allows tablenames with 
>>> small letters????
>>
>>
>>
(Continue reading)

Mican Bican | 9 Feb 2005 08:40
Picon

Re: tables with small letters?

Ben Scherrey schrieb:

> Unfortunately table names that aren't pure lower-case are a bit 
> annoying. I converted an app from Access to Postgres and changing the 
> code for all the table names wasn't an option. Try changing your 
> select statement to: 'select * from "Farbton"' and see if that doesn't 
> work. Everywhere you reference a table name you will have to enclose 
> it in "". Its up to you to decide which is the bigger pain in the butt 
> to deal with, quoting table names or changing them to lower case in 
> the db structure.
>
>    good luck,

Thanks Ben .. this was the problem! So I think I is it better to change 
all to lower case in the db structure. But I dont understand why this is 
so?? PgAdminIII generate a sql code, for example create table "Table" 
... so thats mean when i create table manually with create table Table, 
and write a select statement like this: select * from Table without " 
than its works?? Hmm thanks for your help...
(can I turn off the function in pgAdminIII to add the " in the create 
statements?)

--Muhlis

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
(Continue reading)

Jon-Pierre Gentil | 11 Feb 2005 03:19

Re: tables with small letters?

On Wednesday 09 February 2005 01:40 am, Mican Bican wrote:

> Thanks Ben .. this was the problem! So I think I is it better to change
> all to lower case in the db structure. But I dont understand why this
> is so?? PgAdminIII generate a sql code, for example create table
> "Table" ... so thats mean when i create table manually with create
> table Table, and write a select statement like this: select * from
> Table without " than its works?? Hmm thanks for your help...
> (can I turn off the function in pgAdminIII to add the " in the create
> statements?)

pgAdminIII does precisely as you tell it to.  It will enclose an 
identifier in quotation marks if you specify any capital letters in the 
name.  Thus, afterwords, you must specifically quote the name back to it 
identically otherwise it does not see it correctly.

So the moral of the story is, never use capital letters.  Or stop using 
pgAdminIII.  :)  

--

-- 
_________________________________________________________

  Jon-Pierre Gentil               PGP: 0xA21BC30E
  jabber: jgentil@...    web: www.sebistar.net
  "If you think education is expensive, try ignorance."
_________________________________________________________ 
Karsten Hilbert | 9 Feb 2005 09:13
Picon

Re: tables with small letters?

> Thanks Ben .. this was the problem! So I think I is it better to change 
> all to lower case in the db structure. But I dont understand why this is 
> so??
Read my previous post.

Karsten
--

-- 
GPG key ID E4071346  <at>  wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click

Gmane