I am using Celery with Flask and SQLAlchemy to store some strings into the database. Everything works fine but when I created the database class:
class Locations(db.Model):
id = db.Column('id', db.Integer, primary_key=True)
data = db.Column('data', db.String(50))
def insert():
location="Madrid"
l = Locations(id=id, data=location)
db.session.add(l)
db.session.commit()
And when I access a url page is invokes the method insert(), I get this error, which I assume has something to do with id:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) can't adapt type 'builtin_function_or_method' [SQL: 'INSERT INTO locations (id, data) VALUES (%(id)s, %(data)s)'] [parameters: {'id': <built-in function id>, 'data': 'Oslo'}] (Background on this error at: http://sqlalche.me/e/f405)