flask-sqlalchemy

Git lab CI Running nose tests with SqlAlchemy. ERROR: Failure: TypeError (can't apply this __setattr__ to DefaultMeta object)

无人久伴 提交于 2020-08-09 18:17:29
问题 I am working on a Flask Application with a Postgres database. When I run nose tests locally everything works fine, but when I upload the code to GitLab this happens in my pipeline. I am using gitlab-ci . Any suggestions on how to solve this issue are welcome. $ nosetests --with-coverage --cover-package=app EEEEE ====================================================================== ERROR: Failure: TypeError (can't apply this __setattr__ to DefaultMeta object) ---------------------------------

My API is returning blank json, instead of desired nested schema

∥☆過路亽.° 提交于 2020-08-09 09:24:11
问题 My schema is: import time from marshmallow import fields, Schema from ramas_core.api.resources.base import CamelCaseSchema, base_filters, unfilterable_fields class colorMapLayersSchema(CamelCaseSchema): #raster_layer id = fields.UUID() visibility = fields.Boolean() color_map_type = fields.String() #capture field_id = fields.UUID() event_date = fields.DateTime() event_date_time = fields.String() class gridMapLayersSchema(CamelCaseSchema): #raster_layer id = fields.UUID() visibility = fields

sqlalchemy cant bind order by clause

我是研究僧i 提交于 2020-07-31 05:25:31
问题 I am trying to bind the order by clause and limit clause in my query with no luck using SQLAlchemy print(engine.execute(text('''select vendor_id from vendors ORDER BY :column_n :order_n'''), column_n='vendor_id', order_n='DESC').fetchall()) print(engine.execute('''select vendor_id from vendors order by vendor_id DESC''').fetchall()) Query 2 above is producing the expected output 2 below (of course it is not parameterized): 2020-06-10 10:51:51,126 INFO sqlalchemy.engine.base.Engine select

db.create_all() not creating tables in Flask-SQLAclchemy

天涯浪子 提交于 2020-07-19 05:28:47
问题 I am trying to create a database table for a user class model using Flask-SQLAclchemy and Postgres . My model class. from app import db class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(70), index=True, nullable=False) email = db.Column(db.String(70), index=True, unique=True, nullable=False) password = db.Column(db.String(128)) My app initialisation. from flask import Flask from flask_sqlalchemy import SQLAlchemy app =

Get choices from a DataBase query in wtforms and flask-sqlalchemy

独自空忆成欢 提交于 2020-07-18 08:02:11
问题 I'm developing a web app using Flask, SQLAlchemy and WTForms. I would like to get my choices in a SelectField from a query through my DB. With more details. my_query = my_table.query.with_entities(My_Entities).all() Result [(u'1',), (u'2',), (u'3',)] My class class MyForm(Form): My_Var = SelectField(choices=RIGHT_HERE) Is there any way ? 回答1: In this situation what you can do is use the extensions that are in WTForms. What you do is import the QuerySelectField that you need: from wtforms.ext

Flask-Migrate sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column

不打扰是莪最后的温柔 提交于 2020-07-18 04:02:29
问题 I am using Flask-Migrate in my application, with the following models: listpull/models.py from datetime import datetime from listpull import db class Job(db.Model): id = db.Column(db.Integer, primary_key=True) list_type_id = db.Column(db.Integer, db.ForeignKey('listtype.id'), nullable=False) list_type = db.relationship('ListType', backref=db.backref('jobs', lazy='dynamic')) record_count = db.Column(db.Integer, nullable=False) status = db.Column(db.Integer, nullable=False) sf_job_id = db

TypeError: get_bind() got an unexpected keyword argument

旧巷老猫 提交于 2020-07-16 08:11:29
问题 I am trying to use a database in flask using from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker In it I am created a basic login page and a register page and when I try to use html code: <form action="/login" method="post"> <input autocomplete="off" autofocus name="username" placeholder="Username" type="text"> <input class="form-control" name="password" placeholder="Password" type="password"> <button class="btn btn-primary" type="submit">Log In<

TypeError: get_bind() got an unexpected keyword argument

五迷三道 提交于 2020-07-16 08:10:29
问题 I am trying to use a database in flask using from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session, sessionmaker In it I am created a basic login page and a register page and when I try to use html code: <form action="/login" method="post"> <input autocomplete="off" autofocus name="username" placeholder="Username" type="text"> <input class="form-control" name="password" placeholder="Password" type="password"> <button class="btn btn-primary" type="submit">Log In<

Flask sqlalchemy.exc.OperationalError: (OperationalError) no such table when trying to update database with SQLAlchemy

可紊 提交于 2020-07-16 05:52:22
问题 I'm new to Flask, and having some issues setting up a very basic Flask app. Right now, I'm trying to get the user to submit a form on the homepage and then save that form to a SQL database. However, when the user submits the form, I get the following error sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: contact [SQL: 'INSERT INTO contact (name, email) VALUES (?, ?)'] [parameters: ('aaa', 'aaa')] (Background on this error at: http://sqlalche.me/e/e3q8) Relevant code

Correct way to declare an image field, sqlalchemy

∥☆過路亽.° 提交于 2020-07-06 09:47:47
问题 I am trying to build and app with flask, I have seen some tutorial and books and some code[1] they explain how to declare integers and string for the database setup. However, they do not explain how to store images. I am very confused now I though the natural way to store images was on a database, but reading some documentation on the flask site[2] the filesystem is the place to store images. I just make a first assumption reading a flask development book that a declaration with largeBinary