The Assertion Error "schema is not None" in Flask SQLAlchemy occurs because the function is expecting a schema to be defined in the metadata for the table being queried. If the schema is not defined, the assertion error is thrown. To fix this error, you can add the schema name in the metadata when defining your tables.
For example, you could define a table with the schema name "public" as follows:
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
class MyTable(db.Model):
__tablename__ = 'mytable'
__table_args__ = {'schema': 'public'}
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(50))
Alternatively, you can define the schema as an argument in the has_table assertion.
For example:
assert engine.has_table('mytable', schema='public')
This checks if the table named "mytable" exists in the schema "public".
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-02-19 11:00:00 +0000
Seen: 10 times
Last updated: Dec 23 '21
In PySpark, how does the lead function work when the value of a column changes?
How can SQL output be structured in a column-based XML format instead of row-based?
How can pgcrypto be used to secure data on Postgres?
What is the SQL grammar used for addSql in Doctrine?
How can Django Admin accommodate a variety of formats and locales for its input fields?