Questions tagged [flask-sqlalchemy]

Flask-SQLALchemy is an extension for Flask that provides SQLAlchemy support. It is designed to make database manipulation through SQLAlchemy even easier and simpler. It has the same three clause BSD License as Flask.

Filter by
Sorted by
Tagged with
0
votes
0answers
7 views

Mutually referencing class deadlock

I have two SQLAlchemy class declarations that refer to each other so the first one gives an error because the second one is not yet declared. The records in Key with key_type_id == 4 are references ...
0
votes
0answers
16 views

Stop query execution if count is more than N in postgresql/sqlalchemy

Is there any way to stop the query if count is greater than any number lets say N=50 in postgresql/sqlalchemy, like COUNT STOPKEY in oracle. Thanks
0
votes
0answers
9 views

AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'Column'

This is a duplicate question but I have not figured out any solution for this and it is a basic one. I have installed all the requirements correctly These are the versions I installed Flask==1.1.1 ...
1
vote
1answer
20 views

Flask SQLAlchemy (mysql) connection close (connection timeout)

I'm using Flask SQLAlchemy to connect to my mysql db, but it has defualt wait_timeout 120 seconds, so after I query my users and web isn't used for a while I get an error (2013, 'Lost connection to ...
-1
votes
0answers
15 views

Flask-sqlalchemy reflection. Doesn't reflect constraints

I have a Flask application with a dynamical count of tables. And I do a reflection of these tables tables.query.all() - the list of available tables I do a loop over the list of tables and get class ...
-1
votes
0answers
9 views

python flask 404 page not found

every thing works fine except the last app.route method its giving error page not found i have created create.html in the same directory where post.html and 404.html are they are working fine but the ...
-1
votes
1answer
26 views

Why is my registration form not updating on submit

I'm making a registration form using Flask-wtforms and sqlite as my database but when I try to submit it does not push to the database. I have checked whether i had not put a method of 'post'in my ...
0
votes
1answer
16 views

Flask-SQLAlchemy — One model having two different relationships

I have three models: Role, User, and Post. Role -> User is one to many, and User -> Post is one to many. When I just had User and Post, everything worked. However, my website will need varying degrees ...
0
votes
1answer
13 views

Fetching the value from tables based on some filter condition and pass it to the other table

I want to get the value from the table based on the condition. For example I have a table called studentinfo with two fields studentsid and status. Now I have to fetch the status value through the ...
0
votes
0answers
18 views

Filter attributes with OR and AND from multiple joined tables in SQLALCHEMY produces extra entity

As mentioned in the documentation, sqlalchemy "filter" and "filter_by" filters only "the last entity that was the target of a call to Query.join()" I want to have a query like: SELECT sale.* FROM ...
-1
votes
0answers
24 views

sqlalchemy.exc.OperationalError (sqlite3.OperationalError) no such table: user

I'm running the server and fill the register form but click submit sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: user error is exception. How the fix this problem?...
1
vote
2answers
66 views

Flask-Sqlalchemy: Table with 3 primary keys that are also foreign keys

I am trying to translate a table from pure SQL to Flask-Sqlalchemy, but the documentation available is not clear about how to do this specific scenario - Primary keys that are also foreign keys. The ...
2
votes
0answers
53 views

How to use sqlite json1 features such as json_extract, json_each, json_tree using ORM DB API of flask-sqlalchemy?

I want to use json_extract, json_tree, json_each features of JSON1 Extension enabled sqlite3 database with flask-sqlalchemy. With reference to link here, I am making ORM query as below: Model ...
0
votes
1answer
30 views

Is there a way to avoid duplicate user creation on this case?

I'm creating a Flask App to analyze some behavior in my company. And the intranet website sends me some webhook to tell me when someone logs in somewhere. The problem is that sometimes the intranet ...
0
votes
0answers
41 views

Flask-SQLAlchemy with pyodbc, how to set encoding in connect string

I am using Flask-SQLAlchemy and pyodbc as a connect driver. My connect string: SQLALCHEMY_DATABASE_URI = 'mssql+pyodbc://{user}:{password}@{host}/{name}?driver={driver}&charset={charset}'.format( ...
0
votes
0answers
18 views

Does SQLAlchemy support Firebird 3 yet?

Does SQLAlchemy support Firebird 3? I ask because when using the below model, SA seems to not create the expected DDL (or metadata, not sure of the correct term) for the intended primary key id. ...
0
votes
0answers
10 views

Filter many-many relationship result (flask sqlalchemy)

I have a basic many to many relationship as below, class User(UserMixin, db.Model): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(64), index=True, unique=True) ...
1
vote
0answers
24 views

Querying data with nested relationships

I have a user table that has a relationship to my accounts table. My accounts table has a relationship to the account_permission table which is used to define permissions for accounts. A user may ...
-2
votes
1answer
27 views

Why is Flask saying that my table is undefined?

I have created a flask app with Flask-Sql-Alchemy, however flask in't recognising the database table User_Plans I created and trying to query. It gives the following error: NameError: name '...
1
vote
0answers
23 views

What is direction of many to many bidirectional?

I have a "many to many" bidirectional, but when I create mapping data for Group and User, it's only working with 1 direction. class Groups(db.Model): __tablename__ = 'GROUPS' grpid = db....
0
votes
0answers
6 views

ImportError: No module named 'redisutil'

My App seems to have a an error with this line of code : from redisutil import redis_connection i have install the library redis but i ma using python 2.7 and it says requirement already satisfied . ...
0
votes
0answers
15 views

How to reorder table rows by id with flask-sqlalchemy?

I have table: Table id column_1 column_2 ------------------------------ 1 content_1 content_2 2 content_3 content_4 3 content_5 content_6 And I have sequence of ...
0
votes
0answers
7 views

create partition table using flask sqlalchemy

Hi I have one table Xyz i am trying to create partition table using one of the column value, ex-c in flask alchmey. class Xyz(db.model): c= db.column(string) how can we done through ORM. I have ...
0
votes
0answers
42 views
+50

Sqlite3 Disk I/O error encountered after a while, but worked after using copy of db

I'm using an sqlite3 database to record data every second. The interface to it is provided by Flask-SQLAlchemy. This can work fine for a couple of months, but eventually (as the .db file approaches ...
0
votes
1answer
22 views

What is the proper way to create a table if it doesn't exists. Flask-SQLAlchemy

I want to use my singleton class to load it from database if it doesn't exists. The problem is I didn't find a proper way to do that, but only catching the exceptions. So, I've searched for some ...
0
votes
1answer
16 views

Trying to convert a LATERAL SQL query to SQLA ORM/Core API calls

I have name translations stored in JSONB fields with the format {lang-code: translation} (from sqlalchemy-utils). I'm using jsonb_each_text() for retrieving the names in a query. Below is my model ...
0
votes
1answer
36 views

How to configure model to not create tables in flask sqlAlchemy?

How to configure sqlAlchemy to not create tables in flask sqlAlchemy? i only use flask-sqlalchemy Model's features,but won't create table. How to configure this? because i want to use in sql View,...
-1
votes
0answers
33 views

Choose a Flask encryption extention to encrypt userdata [closed]

I'm currently working on the securisation of the data on my sqlalchemy based database. In dev I'm working with sqlite and in production I'm using a postgresql database on Heroku. So I'm wondering how ...
0
votes
0answers
21 views

Sqlite table may not be dropped error during flask-migrate

I'm working with flask-sqlalchemy and have been trying to migrate an sqlite database after I have defined new tables in my model file. Everything goes just fine when I "flask db migrate", but when I "...
0
votes
0answers
29 views

flask importing app form __init__ not working

I am unable to import app from init.py into models.py I am using Blueprints in Flask. Directory Looks like ss | config.py | models.py | __init__.py +---admin |----| ...
0
votes
1answer
45 views

python 3.7.4 : FLASK_SQLALCHEMY No module named '_sqlite3'

i'm using Debian "Linux mint 19.1" and python 3.7.4 and system have already 2.7 & 3.6 versions ,i create a env but when i start to create database file with db.create_all() i have "... ...
1
vote
1answer
60 views

Dealing with Arrays in Flask-SqlAlchemy and MySQL

I have a datamodel where I store a list of values separated by comma (1,2,3,4,5...). In my code, in order to work with arrays instead of string, I have defined the model like this one: class MyModel(...
0
votes
0answers
20 views

Multiprocessing with flask sqlalchemy - psycopg2.DatabaseError: error with status PGRES_TUPLES_OK and no message from the libpq

am getting below exception while trying to use multiprocessing with flask sqlalchemy. sqlalchemy.exc.ResourceClosedError: This result object does not return rows. It has been closed automatically. [...
0
votes
0answers
18 views

Creating a mysql table using flask-sqlalchemy doesn't work

I'm trying to create a mysql table in the python interpreter with flask-sqlalchemy. I get the error File "/Users/chen97me/Documents/project/instaad/venv/lib/python3.7/site-packages/sqlalchemy/...
0
votes
0answers
12 views

How can I get Flask-SQLAlchemy to make database binds unique to the user who logs in?

I am trying to build a Flask web interface for my Postgresql database which will first require a login verification to Flask and then use the logged-in user information to build the SQL engines so ...
0
votes
0answers
26 views

Login in flask alchemy vs sqlite3

i have been developing a flask app with a sqlite3 database. Now to publish it online i am switching the database from sqlite3 to Sqlalchemy and i am very lost. I implemented a login and registrer but ...
0
votes
1answer
10 views

How can I query categories for blog posts with flask-sqlalchemy?

I would like to show the categories of blog posts (many-to-many-relationship). How can I query them correctly with SQL-Alchemy and show them with Jinja2 in a HTML-Template? models.py category_post = ...
0
votes
1answer
14 views

Alembic fails to upgrade database because of missing VARCHAR length and cannot correct

I ran flask db upgrade and received the error VARCHAR requires a length on dialect mysql So I corrected my VARCHAR by adding the length like this username = db.Column(db.VARCHAR(256)) Then I ran ...
0
votes
0answers
23 views

Unable to retrieve value from many-to-many relationship using flask-sqlalchemy

I am having 3 tables to user,role and user_role(association table). User and Role can have many-to-many relationship. I am using a has_role() function which should return true if the required role is ...
0
votes
0answers
10 views

Fetch the values from two different tables and fetch the output based on primary and foreign key

Fetch the time filed from two different tables based on the passed input value in sqlalchemy and Sqlite I have created models.py and I have added two tables.I have to fetch the time field ...
0
votes
0answers
14 views

how to fix 'passing data from flask-socketio event handler to Flask-SQLAlchemy'

I want to pass event json data from flask-socketio to flask-SQLalchemy Below is my code: from flask import Flask, render_template from flask_socketio import SocketIO, emit from ...
0
votes
0answers
9 views

Save record from dictionary using MongoAlchemy

My model class for user collection looks like this. class User(UserMixin,db.Document): config_extra_fields = 'ignore' first_name = StringField() last_name = StringField() def get_id(...
0
votes
1answer
45 views

From Sqlite3 to Sqlalchemy

i have been developing a flask app with a sqlite3 database. Now to publish it online i am switching the database from sqlite3 to Sqlalchemy and i am very lost. I want to create a users table ("...
0
votes
0answers
12 views

SQLALchemy adds significant overload. SQLAlchemy Object has no attribute 'dateTime

I have issues with my code, trying to setup SQLAlchemy database in flask using python. Code: Thanks for the help. Tried to reinstall SQLAlchemy. I'm using a corporate laptop, shouldn't be a problem?...
0
votes
0answers
16 views

Can't figure out how to link multiple nesting many to many relationships

I'm setting up a user authentication modules to specify three roles: 'r', 'w', 'x', however I can't figure out how to link all the subcomponents of the website. The website has five levels: 1- ...
0
votes
1answer
35 views

Converting a JSON data output to a HTML-TABLE format in Python - Flask?

I have a current API set up in flask-SQLAlchemy that returns an output in JSON format that I'm having trouble putting into a presentable tabular or HTML format. I'd like it to be presented in a more ...
0
votes
1answer
38 views

SQLAlchemy: create sqlalchemy query from sql query with subquery and inner join

I'm new to backend development and python. I'm working on creating a SQLAlchemy query from SQL query which has subquery and inner join. I'm using python > 3.5, "oracle+cx_oracle" driver and ...
1
vote
1answer
52 views

Add relation related columns to many-to-many table flask-sqlalchemy?

I have the following models: class Page(db.Model): id = db.Column(db.Integer, primary_key=True) tags = db.relationship('Tag', secondary=tags, lazy='subquery', backref=db.backref('...
1
vote
3answers
36 views

How to hide MYSQL credentials in SQLAlchemy using Flask application

I'm using MySQL for my Flask application; but I need help for hiding the password in the MySQL user credentials Currently it's like this from flask import Flask from flask_sqlalchemy import ...
0
votes
0answers
24 views

Can I override sqlalchemy relationships in derived classes to return objects of a derived class?

I have two base classes in SQLAlchemy (defined declaratively) with a relationship between them. I then subclass each of these base classes. When I access the relationship in the first derived class, I ...