.....my postgres db class ......
class User(db.Model):
"""docstring for User"""
__tablename__ = 'user'
user_name = db.Column(db.String(45), primary_key=True)
email = db.Column(db.String(45))
def __init__(self, user_name, email):
super(User, self).__init__()
self.user_name = user_name
self.email = email
.....when an insert is attempted I get error message
@app.route('/add_user', methods=['POST'])
def add_user():
user = User(user_name = request.form['user_name'], email = request.form['email'])
print(user.user_name, user.email)
db.session.add(user)
db.session.commit()
return render_template('get_address.html')
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "user" does not exist LINE 1: INSERT INTO "user" (user_name, email) VALUES ('as', 'sd') ^ [SQL: 'INSERT INTO "user" (user_name, email) VALUES (%(user_name)s, %(email)s)'] [parameters: {'email': 'sd', 'user_name': 'as'}]
.....there are multiple schemas that are being used .....the above class is in a schema called users
I think the issue is the table name resolution: i.e in the database where is the table 'users'? I assumed one must qualify the table 'users' with the schema name of __tablename__ = 'users.user'. This does not work.
...the error produced is:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) relation "users.user" does not exist LINE 1: INSERT INTO "users.user" (user_name, email) VALUES ('po', 'p... ^ [SQL: 'INSERT INTO "users.user" (user_name, email) VALUES (%(user_name)s, %(email)s)'] [parameters: {'email': 'po', 'user_name': 'po'}]
I cannot find on SqlAlchemy.org site or anywhere else any info on any construct to be used or how to address this.
Any ideas?