I am trying to create a table using SQLalchemy and geoalchemy2 like so:
class RLocModel(Base):
__tablename__ = 'rloc'
id = Column(Integer, primary_key=True)
loc = Column(Geometry('POINT'))
This is against a mysql database (actaully a AWS mysql compatible Aurora database).
I get an exception as follows:
(_mysql_exceptions.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(POINT,-1), \n\tPRIMARY KEY (id)\n)' at line 3") [SQL: '\nCREATE TABLE rloc (\n\tid INTEGER NOT NULL AUTO_INCREMENT, \n\tloc geometry(POINT,-1), \n\tPRIMARY KEY (id)\n)\n\n']
I am not sure it is expressing the correct dialect.
I can do this manually as so:
CREATE TABLE `geo` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`loc` geometry NOT NULL,
PRIMARY KEY (`id`),
SPATIAL KEY `loc` (`loc`)
) ENGINE=InnoDB AUTO_INCREMENT=11905 DEFAULT CHARSET=latin1;
Any ideas?
According to documentation:
What you can do is to create the custom
Point
type:Now, you just use this custom type inside your model:
Then you can use your model like this: