[sqlalchemy] getting error with column name end using geoalchemy2

2014-06-21 Thread Chung WONG
Hi list,
I am encountering a very strange error and I am scratching my head and got 
no idea what is going on. 

class Line(Base):
__tablename__ = 'lines'
id = Column(Integer, Sequence('line_id_seq'), primary_key=True)

start = Column(Geometry('POINT'), nullable=False, *index=False*)
*end* = Column(Geometry('POINT'), nullable=False, *index=False*)


On creating this table, it threw a strange error:

*sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at or 
near end*
*LINE 1: ...INDEX idx_lines_end ON public.lines USING GIST (end)*
*   ^*
* 'CREATE INDEX idx_lines_end ON public.lines USING GIST (end)' {}*


The created table is :

CREATE TABLE lines
(
  id integer NOT NULL,
  start geometry(Point) NOT NULL,
  *end* geometry(Point) NOT NULL,
  CONSTRAINT lines_pkey PRIMARY KEY (id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE lines
  OWNER TO postgres;

CREATE INDEX idx_lines_start
  ON lines
  USING gist
  (start);

It is weird there are quotes surrounding the word *end* , and although I 
have specified *index=False*, for some reason indexs are still created 
automatically.
Anything other than *end*, such as *end_, end1 *worked perfectly.
Is end a keyword for *postgis* or *geoalchemy2*?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] getting error with column name end using geoalchemy2

2014-06-21 Thread Cornelius Kölbel
I once had a very strange error with a table called audit on an oracle
database.
It turned out, that exspecially on oracle audit was a reserved word -
while it worked out fine on any other database.

I would recommend trying to use other column names.
As end is surrounded by double quites your database postgres also know
it as a reserved word. (see
https://stackoverflow.com/questions/5570783/using-end-as-column-name-in-ruby-on-rails-mysql)

Change the column name.

Kind regards
Cornelius

Am 21.06.2014 14:34, schrieb Chung WONG:
 Hi list,
 I am encountering a very strange error and I am scratching my head and
 got no idea what is going on. 

 class Line(Base):
 __tablename__ = 'lines'
 id = Column(Integer, Sequence('line_id_seq'), primary_key=True)

 start = Column(Geometry('POINT'), nullable=False, *index=False*)
 *end* = Column(Geometry('POINT'), nullable=False, *index=False*)


 On creating this table, it threw a strange error:

 /sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at
 or near end/
 /LINE 1: ...INDEX idx_lines_end ON public.lines USING GIST (end)/
 /   ^/
 / 'CREATE INDEX idx_lines_end ON public.lines USING GIST (end)' {}/


 The created table is :

 CREATE TABLE lines
 (
   id integer NOT NULL,
   start geometry(Point) NOT NULL,
   *end* geometry(Point) NOT NULL,
   CONSTRAINT lines_pkey PRIMARY KEY (id)
 )
 WITH (
   OIDS=FALSE
 );
 ALTER TABLE lines
   OWNER TO postgres;

 CREATE INDEX idx_lines_start
   ON lines
   USING gist
   (start);

 It is weird there are quotes surrounding the word *end* , and although
 I have specified *index=False*, for some reason indexs are still
 created automatically.
 Anything other than *end*, such as *end_, end1 *worked perfectly.
 Is end a keyword for *postgis* or *geoalchemy2*?

 Thanks
 -- 
 You received this message because you are subscribed to the Google
 Groups sqlalchemy group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to sqlalchemy+unsubscr...@googlegroups.com
 mailto:sqlalchemy+unsubscr...@googlegroups.com.
 To post to this group, send email to sqlalchemy@googlegroups.com
 mailto:sqlalchemy@googlegroups.com.
 Visit this group at http://groups.google.com/group/sqlalchemy.
 For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] getting error with column name end using geoalchemy2

2014-06-21 Thread Mike Bayer

On 6/21/14, 8:34 AM, Chung WONG wrote:
 Hi list,
 I am encountering a very strange error and I am scratching my head and
 got no idea what is going on. 

 class Line(Base):
 __tablename__ = 'lines'
 id = Column(Integer, Sequence('line_id_seq'), primary_key=True)

 start = Column(Geometry('POINT'), nullable=False, *index=False*)
 *end* = Column(Geometry('POINT'), nullable=False, *index=False*)


 On creating this table, it threw a strange error:

 /sqlalchemy.exc.ProgrammingError: (ProgrammingError) syntax error at
 or near end/
 /LINE 1: ...INDEX idx_lines_end ON public.lines USING GIST (end)/
 /   ^/
 / 'CREATE INDEX idx_lines_end ON public.lines USING GIST (end)' {}/


 The created table is :

 CREATE TABLE lines
 (
   id integer NOT NULL,
   start geometry(Point) NOT NULL,
   *end* geometry(Point) NOT NULL,
   CONSTRAINT lines_pkey PRIMARY KEY (id)
 )
 WITH (
   OIDS=FALSE
 );
 ALTER TABLE lines
   OWNER TO postgres;

 CREATE INDEX idx_lines_start
   ON lines
   USING gist
   (start);

 It is weird there are quotes surrounding the word *end* , and although
 I have specified *index=False*, for some reason indexs are still
 created automatically.
 Anything other than *end*, such as *end_, end1 *worked perfectly.
 Is end a keyword for *postgis* or *geoalchemy2*?
end is likely a reserved word, there's nothing wrong with using it as
a column name as SQLAlchemy will quote it, though the other poster has a
point that it's always better to avoid reserved words if for no other
reason than reducing verbosity.

as far as the Index i don't have an insight on the index being created
or not, if perhaps geoalchemy is involved there, not really sure.See
if changing the Geometry type to something else temporarily changes things.

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.


Re: [sqlalchemy] getting error with column name end using geoalchemy2

2014-06-21 Thread Jonathan Vanasco
`END` is a reserved keyword in most SQL dialects, including the ANSI sql 
standards.  I think mysql is the only major database that allows it.

Here's a link to a collection of all known reserved keywords across 
databases, with links to relevant documentation for each particular 
standard.

https://www.drupal.org/node/141051

-- 
You received this message because you are subscribed to the Google Groups 
sqlalchemy group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.