Linked Questions
35 questions linked to/from How to execute raw SQL in Flask-SQLAlchemy app
6
votes
2
answers
7k
views
How to get all values from same column? [duplicate]
I am developing web framework using python. below is my database. this database name is fruit.
name price
----- -----
apple $2
pear $2
grape $4
I am using SQLAlchemy. so class name ...
1
vote
0
answers
275
views
group_concat string getting truncated [duplicate]
I have two tables as follows:
class Workflows():
__tablename__ = 'workflows'
id = db.Column(db.Integer(), primary_key=True)
name = db.Column(db.Unicode(255),unique=True)
class Tasks(): ...
30
votes
10
answers
159k
views
SQLAlchemy execute() return ResultProxy as Tuple, not dict
I have the following code:
query = """
SELECT Coalesce((SELECT sp.param_value
FROM sites_params sp
WHERE sp.param_name = 'ci'
AND sp....
65
votes
4
answers
162k
views
What is parameterized query? [duplicate]
What is a parameterized query, and what would an example of such a query be in PHP and MySQL?
60
votes
1
answer
66k
views
sqlalchemy : executing raw sql with parameter bindings
I'm trying to run this simple raw sql statement with parameters with SQLALchemy (within an alembic script) :
from alembic import op
t = {"code": "123", "description": "one two three"}
op.execute("...
26
votes
3
answers
70k
views
AttributeError: 'Engine' object has no attribute 'execute' when trying to run sqlalchemy in python to manage my SQL database
I have the following line of code that keeps giving me an error that Engine object has no object execute. I think I have everything right but no idea what keeps happening. It seemed others had this ...
20
votes
1
answer
58k
views
Sqlalchemy, raw query and parameters
I am trying to perform raw sql query using sqlalchemy and wondering what is a 'proper' way to do it.
My query looks as follows (for now):
db.my_session.execute(
"""UPDATE client SET musicVol = {}...
5
votes
2
answers
8k
views
Flask-SQLAlchemy: How to change table structure?
I have a table model in a flask application:
class Article(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True)
title = db.Column(db.String(80), nullable=False)
...
1
vote
1
answer
12k
views
How do I prevent SQL injections in Flask-SQLAlchemy? Is there a better way to load data from CSV?
I am trying to quickly load data from the internet into a table using Flask, SQLAlchemy with PostgreSQL/psycopg2. I am in a slight argument with a co-worker. We will call him "Dad." Dad is ...
3
votes
2
answers
3k
views
Get single value from PostgreSQL row object using SQLAlchemy
I am using Python with SQLAlchemy (and GeoAlchemy in my particular case), and I have a query that results in a single column of row objects. I wish to extract particular values from these row objects, ...
2
votes
2
answers
4k
views
Load Data Local Infile with SQLAlchemy and pymysql
I'm trying to using LOAD DATA LOCAL INFILE but I continue to get:
sqlalchemy.exc.ProgrammingError: (pymysql.err.ProgrammingError) (1064, "You have an error in your SQL syntax; check the manual that ...
1
vote
1
answer
7k
views
Using string_agg() function in sqlalchemcy with SQL Server 2017
Task at hand is to aggregate the values into comma-separated string using SqlAlchemy with SQL Server 2017:
So I use string_agg() to do so:
query = session.query(Table.key, func.string_agg(Table.value,...
5
votes
1
answer
1k
views
Create a database trigger in an event listener
I have a flask API and I'm using Flask-SQLAlchemy to handle a SQLite database. I have a table which stores log entries, and I want to limit the maximum number of rows to a number n. Since insertions ...
1
vote
1
answer
4k
views
SQLAlchemy: update & delete value from database
I'm newer in SQLAlchemy I use some examples to create table and insert information to it and it's working 100% .
But what I didn't find is some example for how can I update & delete some ...
6
votes
1
answer
2k
views
Commiting a transaction from a PostgreSQL function in flask
I'm a newbie to Flask and SQLAlchemy (been working with Django for the last 3 years). I need to call an existing PostgreSQL function that writes to 3 different tables in a database. This is out of my ...