flask-sqlalchemy

SQLAlchemy cannot connect to Postgresql on localhost

。_饼干妹妹 提交于 2021-02-19 04:24:45
问题 I'm sure this is such an easy error to fix, if I could only find where it is. This is the error from the Flask app: 11:58:18 web.1 | ERROR:xxxxxx.core:Exception on / [GET] 11:58:18 web.1 | Traceback (most recent call last): 11:58:18 web.1 | File "/Library/Python/2.7/site-packages/flask/app.py", line 1817, in wsgi_app 11:58:18 web.1 | response = self.full_dispatch_request() 11:58:18 web.1 | File "/Library/Python/2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request 11:58:18 web

Flask WTF form not updating with the sqlite3 database

空扰寡人 提交于 2021-02-18 18:09:52
问题 I have a RadioField form item that uses values for its field from the database. If the database is not created I cannot start the Flask Webserver even though it should only access the database when I go to that page and load that form. If I update the database while the Webserver is running I don't see the form with the new database information. Until I restart the Flask webserver. How can I get it so that it forces the form to reload its values from the database when you visit the page. Also

What is the correct way to use distinct on (Postgres) with SqlAlchemy?

点点圈 提交于 2021-02-18 16:56:03
问题 I want to get all the columns of a table with max(timestamp) and group by name. What i have tried so far is: normal_query ="Select max(timestamp) as time from table" event_list = normal_query \ .distinct(Table.name)\ .filter_by(**filter_by_query) \ .filter(*queries) \ .group_by(*group_by_fields) \ .order_by('').all() the query i get : SELECT DISTINCT ON (schema.table.name) , max(timestamp).... this query basically returns two columns with name and timestamp. whereas, the query i want : SELECT

What is the correct way to use distinct on (Postgres) with SqlAlchemy?

↘锁芯ラ 提交于 2021-02-18 16:55:28
问题 I want to get all the columns of a table with max(timestamp) and group by name. What i have tried so far is: normal_query ="Select max(timestamp) as time from table" event_list = normal_query \ .distinct(Table.name)\ .filter_by(**filter_by_query) \ .filter(*queries) \ .group_by(*group_by_fields) \ .order_by('').all() the query i get : SELECT DISTINCT ON (schema.table.name) , max(timestamp).... this query basically returns two columns with name and timestamp. whereas, the query i want : SELECT

Periodic “Lost connection to MySQL server during query” after Dockerizing Flask Web App

主宰稳场 提交于 2021-02-18 06:37:40
问题 I have a Flask web app that used to run on a standalone server using the following: Flask/SQLAlchemy MariaDB uwsgi nginx On the stand alone server this application ran fine. I have since "dockerized" this application across two containers: uwsgi-nginx-flask MariaDB Every since dockerizing I occasionally get this error (entire traceback posted at the end): Lost connection to MySQL server during query The MariaDB log shows the following errors with verbose logging: 2020-05-10 18:35:32 130

Sqlalchemy error, multiple foreign keys references to the same table and column

扶醉桌前 提交于 2021-02-17 06:44:05
问题 I already tried a solution from this question and this but failed (on of these solutions are present here), I don't know what to say additionally, logically both FK (sender and recipient) must be present in users, technically all looks are correct here class User(Base): __tablename__ = "users" # # # META # # # id = Column(Integer, primary_key=True, index=True) email = Column(String, unique=True, index=True, nullable=False) # # # RELATIONSHIPS # # # messages = relationship("Message", back

Flask/WTForms/QuerySelectField - render QuerySelectField with a choice selected based on existing database value

孤街浪徒 提交于 2021-02-16 16:13:55
问题 I am building a simple CMS that includes a profile management page. On this profile page, along with other fields, there exists a dropdown list, which I generate from a table 'parks' using the wtforms extension's QuerySelectField: from wtforms.ext.sqlalchemy.fields import QuerySelectField The rest of the fields on the profile page are populated by the 'user' table. Let assume that a user has logged in, and that their record in the 'user' table is already populated. Among the fields in the

How to use SQLAlchemy to create a full text search index on SQLite and query it?

我是研究僧i 提交于 2021-02-16 13:40:26
问题 I am create a simple app which can performance basic operations. SQLite is used as database. I want to perform wildcard search but I know that it has poor performance. I want to try out full text search but I cannot full a example on how to do it. I confirmed that SQLite has full text search support. Here is my sample code. from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class Person(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text, unique=True,

How to use SQLAlchemy to create a full text search index on SQLite and query it?

被刻印的时光 ゝ 提交于 2021-02-16 13:40:09
问题 I am create a simple app which can performance basic operations. SQLite is used as database. I want to perform wildcard search but I know that it has poor performance. I want to try out full text search but I cannot full a example on how to do it. I confirmed that SQLite has full text search support. Here is my sample code. from flask_sqlalchemy import SQLAlchemy db = SQLAlchemy() class Person(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.Text, unique=True,

AttributeError: Object has no attribute 'user_loader'

丶灬走出姿态 提交于 2021-02-11 14:40:56
问题 I'm programming a Website with Authentification while using the Flask Framework. I've tried every solution that i found on the internet but nothing worked for me. My first idea was, that the Project Structure was corrupt. e.g. missing imports from other files. But thats not the problem i think. My models.py File: from flask_login import UserMixin, LoginManager from flaskapp import db, login_manager @login_manager.user_loader def get_user(user): try: return get_id(user) except: return None