Tagged Questions
1
vote
1answer
20 views
Ordering and pagination in SQL-alchemy using non-sql ranking
I have a python algorithm which returns a rank ordering of database rows for a given user. This algorithm outputs a list of primary key ids (these keys could be joined with post.id). It looks like the ...
0
votes
1answer
33 views
Sort by Count of Many to Many Relationship - SQLAlchemy
I am using Flask-SQLAlchemy to to query my Postgres database.
I am currently trying to query for suggestions of titles with the following query:
res = ...
0
votes
0answers
19 views
SQLAlchemy complex query
Today I'm facing a problem with an sqlalchemy query. I've tried for a while now but I can't figure out what I'm doing wrong.
I'm quite new to this whole story of sqlalchemy, I've started to become ...
0
votes
0answers
13 views
“Query has no attribute 'whoosh_search” AttributeError in Flask + Whoosh + SQLAlchemy
I have a strange problem with Flask-WhooshAlchemy as well as Flask-Whooshee that resembles these issues:
https://github.com/gyllstromk/Flask-WhooshAlchemy/issues/13
...
1
vote
3answers
540 views
Flask - ImportError: No module named migrate.versioning
I'm working through a flask tutorial and am trying to run a script that creates a database instead of doing it through the command line. It uses the SQLAlchemy-migrate package, but when I try to run ...
0
votes
1answer
13 views
How to have a 'broad filter' in SQLAlchemy query search [duplicate]
I have a SQLAlchemy model called Report, and want to search with a country filter.
Suppose the database has saved the data like "India", "Pakistan", etc.
queries = ...
0
votes
1answer
29 views
Convert SQL to SQL alchemy
I am new to Flask SQl alchemy; Though i understand that alchemy abstracts the sql syntax and makes things easy while creating models; there could be times when we want to visualize data in the front ...
8
votes
2answers
1k views
Flask-SQLAlchemy: Photo column type
In a web application I'm coding with Flask/SQLAlchemy, several of my models needs a "Photo" column type, which would handle storing the original image somewhere on the filesystem, and creating ...
0
votes
1answer
28 views
sqlalchemy one to many join in flask app to get max date
My Data
rowid, job (not unique), status, date.
Query need
Return results unique by job
max date of status ==1 and
max date of status== 0
on the same returned row.
why doesn't this work (and is this ...
0
votes
1answer
30 views
Model in Sqlalchemy
In each workspace i need to add many users, I need connection to for example 5 users how can i handle this sqlalchemy ?
My model is like this :
class User(db.Model):
__tablename__ = 'users'
...
0
votes
1answer
14 views
Remove a relation many-to-many (association object) on Sqlalchemy
I'm stuck with a SqlAlchemy problem.
I just want to delete an relation. This relation is made by an association object.
models
class User(db.Model, UserMixin):
id = ...
3
votes
1answer
43 views
Sharing SQLite3 database between multiple programs
I've begin building a web application using Flask and Flask-SQLAlchemy. My experience with building web applications is very limited so I apologize before hand if I am being ambiguous.
The database ...
0
votes
0answers
11 views
How to do a group_by and count in flask-sqlalchemy? [duplicate]
In my app every user can be a member of an organization. The user's job is to make calls. On every organization's page I want to show a leaderboard showing which users have made the most calls. Here ...
0
votes
1answer
15 views
Query One to Many Relationship SQLAlchemy
I am trying to query the users based upon their skills from these tables.
class User(UserMixin, db.Model):
__tablename__ = 'users'
id = db.Column(db.Integer, primary_key=True)
email = ...
1
vote
0answers
10 views
Access data from existing table using Flask-Alchemy
I know MySQL very well and writing queries is easy but there are time when it becomes too complicated and so i decided to choose an ORM (SqlAlchemy).
I am using Flask as my framework and so i am ...
0
votes
1answer
26 views
using Flask-Migrate together with Flask-Security
I'm trying to get a basic Flask-Security app working with Flask-Migrate. I have two main py files: app.py and db_migrate.py
app.py:
from flask import Flask, render_template, request, session
from ...
0
votes
1answer
16 views
Why an UnmappedInstanceError while populating a database using Flask-SQLAlchemy?
I'm new to SQLAlchemy and am using Flask-SQLAlchemy for my current project. I'm getting an error that has me stumped:
sqlalchemy.orm.exc.UnmappedInstanceError: Class ...
0
votes
1answer
44 views
Flask and SQLAlchemy db.session.commit not working
Please please any one help.. I have been trying this for almost two hours now, but it won't work..
The problem is, when I add a test user to the User table, it adds fine and it is fine even when i ...
0
votes
1answer
19 views
How can insert a new object in one table after updating another table in flask-sqlalchemy
I am using Flask-Sqlalchemy orm in my project.
I have to insert a new object in one table, whenever there is an update on another table.So, I chose models_committed signal.But, the object is not ...
2
votes
2answers
1k views
Pythonic way to correctly separate Model from application using SQLAlchemy
I'm having a hard time to make my application run. Flask-SQLAlchemy extension creates an empty database whenever I try to separate module in packages. To better explain what I'm doing, let me show how ...
7
votes
3answers
3k views
How to use Flask-SQLAlchemy in a Celery task
I recently switch to Celery 3.0. Before that I was using Flask-Celery in order to integrate Celery with Flask. Although it had many issues like hiding some powerful Celery functionalities but it ...
0
votes
1answer
30 views
SQLAlchemy: Populate instance attributes from Database query
I'm using SQLAlchemy with the below User model to track users on my site. I'm trying to get the __init__ method to populate all of the fields in the class instance once it's passed a valid user id, ...
0
votes
1answer
22 views
Receiving “No Such Table” error while trying to access existing MySQL database using Flask and SQLAlchemy
myapp.py
#!flask/bin/python
from flask import Flask, request, jsonify
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__)
db = SQLAlchemy(app)
app.config['SQLAlchemy_DATABASE_URI'] = ...
1
vote
1answer
34 views
Bad request for POST with relationship using flask-restless
I'm using flask-restless and getting a Bad Request (400) error on my first POST (from Postman). If I keep on making the same request, it keeps on erroring. But if I remove the field that ...
1
vote
1answer
47 views
inserting variables and looping over a python class call
I'm using flask-sqlalchemy and flask-wtf. Basically I want to take the string produced by my "row.form_field" query and place it into my wtf form class call. Any ideas on how I can pull this off?
...
0
votes
0answers
18 views
SQLAlchemy Object already attached to session
I'm trying to get a server for an app working, but I'm getting an error upon login:
[!] Object '<User at 0x7f12bc185a90>' is already attached to session '2' (this is '3')
It seems the session ...
9
votes
3answers
2k views
How to build a flask application around an already existing database?
I already have an existing Database that has a lot of tables and a lot of data in MySQL. I intend to create a flask app and use sqlalchemy along with it. Now I asked out on irc and looked around on ...
0
votes
0answers
14 views
Convert this sql statement to sqlalchemy correctly, is the sql optimal?
I have models as such:
class EmployeeTeam(db.Model):
__tablename__ = 'teams'
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(140), nullable=False)
department = ...
1
vote
1answer
18 views
sqlalchemy query duration logging
My apologies if this has already been asked, but I couldn't find exactly what I was looking for.
I'm looking for the best way to log the duration of queries from sqlalchemy to syslog.
I've read ...
3
votes
1answer
50 views
Flask-SQLAlchemy Can't Create Relationship - SAWarning
I used fbone to start this project off and I'm using its implementation of a Flask-SQLAlchemy column extension named DenormalizedText. I get the concept of this and how it works (not my issue) but my ...
3
votes
0answers
83 views
Flask-SQLAlchemy many-to-many ordered relationship in hybrid_property
I am trying to get the first object out of an ordered many-to-many relationship using Flask-SQLAlchemy.
I would like to accomplish this using hybrid properties, so I can reuse my code in a clean way.
...
0
votes
1answer
18 views
pass in table name to sqlalchemy query through url in flask
In short, how do i
var="TableName"
models.var.query.all()
explanation
My goal is to allow the user to change the order of list of items.
I set up an ajax call that sends an array of id's to the ...
1
vote
1answer
328 views
pip install sqlalchemy-migrate crashes and burns inexplicably
Running Python in a virtualenv under Windows 8 x64, working my way through the flask megatutorial. There's a very thorough setup guide, and one of the things I have to do is install ...
1
vote
0answers
41 views
Many to many join with multiple database connections using Flask-SQLAlchemy
I am having issues making many-to-many join work with multiple database connections using Flask-SQLAlchemy as in Many-to-many multi-database join with Flask-SQLAlchemy but with a little twist, one ...
0
votes
0answers
15 views
SQLAlchemy raises UnicodeEncodeError when committing binary data
I am using MySQL with Flask-SQAlchemy
Here is the error I am getting:
StatementError: 'ascii' codec can't encode characters in position 32-37: ordinal not in range(128)
(original cause: ...
0
votes
1answer
14 views
Saving SQLAlchemy models to file
I'm coming from EntityFramework. I'm used to creating my db, running EF, and having a bunch of class files generated for each of my db objects (usually tables) filled with properties (usually ...
0
votes
1answer
48 views
In python flask how to allow a user to re-arrange list items and record in database
I have a flask sqlalchemy bootsrap app.
My template renders a list of items in a table that I would like the user to be able to rearrange. The items get displayed through standard jinja2
{% for ...
0
votes
1answer
50 views
Improving view function in Flask
Below is an example of the page I'm making. In this example, I have two select fields that are used to filter the results on the right side when the submit button is pressed.
The way I solved the ...
0
votes
0answers
39 views
database management of Large Application in Flask
I am developing an application with subdomain support using Flask, SQLAlchemy. The general concept of that app is it has users that are from different cities of a contry and subdomains will be names ...
0
votes
1answer
32 views
flask-restless with mod_wsgi can't connect to MySQL server
I am trying to run a flask-restless app in apache using mod_wsgi. This works fine with the development server. I have read everything I can find and none of the answers I have seen seem to work for ...
1
vote
2answers
32 views
How do you update multiple values in flask-sqlalchemey?
How do you update multiple values?
predictions=Fixture_prediction.query\
.filter_by(user_id=user_id)\
.update(request.form['home_score'],request.form['away_score'])
This is the error I get:
...
1
vote
0answers
37 views
Flask-sqlalchemy use only one connection to mysql
I have Flask application with Flask-sqlalchemy extension.
All my requests are going through one connection to mySQL. So, if one of user get page with long query — all outhers are waiting for end of ...
1
vote
0answers
36 views
Using Flask-SQLAlchemy Event API to broadcast to Flask-SocketIO?
I'm a novice developing a simple multi-user game (think Minesweeper) using Flask for the API backend and AngularJS for the frontend. I've followed tutorials to structure the Angular/Flask app and I've ...
0
votes
1answer
27 views
GeoAlchemy ST_DWithin implementation
Hi! I need to implement a query using GeoAlchemy to get all the Points that are near a given Point (for example, within a 10 meter radius). For storing points, i am using Geography fields in my ...
7
votes
2answers
8k views
Flask-SQLAlchemy: How to conditionally insert or update a row
My application uses a combination of Flask, Flask-SQLAlchemy, Flask-WTF and Jinja2.
In its current incarnation, I have a settings table. The table will only have one record with one field. Initially ...
1
vote
4answers
1k views
Readonly text field in Flask-Admin ModelView
How can I make a field on a ModelView readonly?
class MyModelView(BaseModelView):
column_list = ('name', 'last_name', 'email')
2
votes
2answers
60 views
Flask-WTF form posts successfully but validation never occurs
I have been struggling around the WTF forms for quite a while now. But this error, never seems to go away. I When ever I try to run this code the form never validates
Views :
...
31
votes
6answers
17k views
jsonify a SQLAlchemy result set in Flask
I'm trying to jsonify a SQLAlchemy result set in Flask/Python.
The Flask mailing list suggested the following method ...
2
votes
1answer
37 views
Dynamically create and persist models in Flask - Sqlalchemy [closed]
I am writing a flask webapp. I need to be able to create a model based on user input and create a table based on the model. Further, I also want to be able to use that model later (after having ...
1
vote
1answer
22 views
SQL Alchemy Flask Delete
If I run the following query:
a = db.session.query(Submission).filter_by(id=todelid,deletioncode=todelcode).count()
and I print a, it returns 1.
However when I run the following:
...