I have a database app, and want to create the tables and database on the fly when starting the app for the first time. If the app is restarted, it should only create the database and tables if they do not exist, otherwise ignore this creation. I have a few questions. 1.) Is this a proper way of dealing with
Tag: flask-sqlalchemy
AttributeError: ‘NoneType’ object has no attribute ’email’. Flask-sqlalchemy
i’ve a strange problem… i do this: and gives me this problem: Who can help me?? thanks <3 Answer it means it didn’t find any users matching your filter
First row of all groups in Flask SQLAlchemy
I want to group the database by gauge_id and then get the row having maximum time_col. This is my current code: But I am only able to get both gauge_id and time_col. When I add another column (reading), like this: it gives this error. How do I return the top row of each groups? Thanks in advance. Answer One way
ORM query many to many to one, Flask sql-alchemy
I have three flask-sqlalchemy-models. Books – unique entries by admin: class Book(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) book_name = db.Column(db.String(20)…
Convert PostgreSQL COUNT … FILTER query to SQL Alchemy
I’m new to SQLAlchemy, and I would like to convert this PostgreSQL query: I have already tried this: Thank you in advance for your help Answer Thanks to @IljaEverilä’s comment, here is a more direct answer: (Original answer) I’m not sure if SQLAlchemy’s postgresql dialect specifically handles COUNT … FILTER, but you can accomplish the same thing using SUM and
Best practice for scaling SQL queries on joins?
I’m writing a REST api that works with SQL and am constantly finding myself in similar situations to this one, where I need to return lists of objects with nested lists inside each object by querying over table joins. Let’s say I have a many-to-many relationship between Users and Groups. I have a User table and a Group table and
Flask SQLAlchemy query join
I have 2 table like this: Then I try to making 2 kinds of query to get data for the relationship models. first, I make it like this: and the second one I use join statement on that: My questions are, what’s the difference in that query while in the second one I use the join statement but the result
Querying association table object directly
I have to query the relationships directly, since I have to display them seperatly. task_user = db.Table( ‘pimpy_task_user’, db.Column(‘task_id’, db.Integer, db.ForeignKey(‘pimpy_task.id’)), …