Marcin Krol <mrkafk@gmail.com> writes:
> Michael Wood wrote:
>> It seems SQLAlchemy lied to you about creating the table, or perhaps
>> you did not check an error code or something.
>>
>> blah=> create table user (id int);
>> ERROR: syntax error at or near "user"
>> LINE 1: create table user (id int);
> Apparently it did lie, bc I was able to write objects to that table
> without problems IIRC.
It's fairly likely that what SQLAlchemy actually did was to double-quote
"user" in the commands it issued for you. Observe:
regression=# create table user (id int);
ERROR: syntax error at or near "user"
LINE 1: create table user (id int);
^
regression=# create table "user" (id int);
CREATE TABLE
regression=# select * from user;
current_user
--------------
postgres
(1 row)
regression=# select * from "user";
id
----
(0 rows)
Without quotes, user is a reserved word that selects a SQL-standard
function. With quotes, it's just an identifier that you can use to
name a table if you choose.
regards, tom lane