flask-sqlalchemy

SQLAlchemy cannot find referenced table via foreignkey in many-to-many relationship

SQLAlchemy cannot find referenced table via foreignkey in many-to-many relationship Question: I have already succeeded in adding one many-to-many relationship in my database. However, when trying to add another, I am met with: sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column ‘user_shiftTemplate.template_id’ could not find table ‘shifttemplate’ with which to generate a foreign key to target column …

Total answers: 2

SQLAlchemy column passed as dropdown list in WTForm Flask

SQLAlchemy column passed as dropdown list in WTForm Flask Question: I want to take the values of a column named hotelName from Hotel model and populate with them a dropdown list. I have tried this as a way to put them in my wtform: class RoomForm(FlaskForm): hotel = SelectField(choices=[(h, h) for h in Hotel.hotelName.property.columns[0].type But …

Total answers: 1

Fetch two columns from db using SQLalchemy

Fetch two columns from db using SQLalchemy Question: I am learning python and trying to create a drop-down in my form with the data from another table. here is my code Models.py class empmasterModel(db.Model): __tablename__ = "empmaster" Empnum = db.Column(db.Integer, primary_key=True) Employee_Number = db.Column(db.Integer(),primary_key=True,unique = True) Employee_Name = db.Column(db.String()) Employee_Type = db.Column(db.String()) Coreid = db.Column(db.String()) …

Total answers: 1

How to using sum function with encrypted column in SQLAlchemy?

How to using sum function with encrypted column in SQLAlchemy? Question: I have used EncryptedType from sqlalchemy_utils to encrypt data of the specific column which will make when inserting data into the table or selecting data, the data of encrypted column will be encrypted. This is the ORM structure of my database which have encrypted …

Total answers: 1

SQLAlchemy Joining 2 CTE Results in Ambiguous ON Clause

SQLAlchemy Joining 2 CTE Results in Ambiguous ON Clause Question: I’m attempting retrieve a max version for either a published version or, if a resource has no published versions, the highest version. I’m using 3 CTE to find these values, one to get the max version that is published, a second to get the max …

Total answers: 2

Checking value inside Sqlalchemy queried data

Checking value inside Sqlalchemy queried data Question: I am querying Tags table and storing its values into varialble all_tags = Tag.query.all() # <- Query all existing tags Output: >>> all_tags [<Tag>: STM32, <Tag>: Linux, <Tag>: Unix, <Tag>: Skype, <Tag>: MCU, <Tag>: CPU, <Tag>: Silk, <Tag>: WAN] I am receiving tag values from json client, after …

Total answers: 1

Strange error when trying to get data from database in another file

Strange error when trying to get data from database in another file Question: I was trying to get count of items in databases. Getting count with second database is working as planned, but the first one is giving me this error KeyError: <weakref at 0x000001E85C863330; to "Flask" at 0x000001E8397750D0> This program is a very simplified, …

Total answers: 1

Python flask not working with url containing "?"

Python flask not working with url containing "?" Question: I am new to flask and I was trying to make GET request for url containing "?" symbol but it look like my program is just skipping work with it. I am working with flask-sql alchemy, flask and flask-restful. Some simplified look of my program looks …

Total answers: 2