Questions tagged [sqlalchemy]

SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL.

Filter by
Sorted by
Tagged with
7
votes
1answer
10k views

Efficient Pandas to MySQL “UPDATE… WHERE”

I have a pandas DataFrame and a (MySQL) database with the same columns. The database is not managed by me. I want to update the values in the database in an "UPDATE... WHERE" style, updating only ...
6
votes
2answers
762 views

A simple library using Flask and SQLAlchemy

This is the main.py script that does most of the work of Adding movies (Movie objects) as well as modifying and removing: ...
4
votes
0answers
186 views

SQL-Alchemy session management

I have written a couple of scripts for accessing Twitter REST API, and storing data in a Postgres DB for data extraction purposes. I know how to use django ORM, or plain SQL, but this was my first ...
3
votes
2answers
119 views

Finding the duration of how long a search has been popular

Program: I have designed a program in python that does the following (in order): Webscrapes google trends for the most popular searches Stores the searches and traffic of the searches in an in-memory ...
3
votes
1answer
104 views

Catching API changes for a service that doesn't version its API

I'm using the old Google Data API to access several spreadsheets and put their contents in a database using Flask and SQLAlchemy. Each run deletes the contents of the database tables and repopulates ...
3
votes
1answer
1k views

Joining two KeyedTuple objects in SQLAlchemy

I have the following two queries: ...
3
votes
1answer
1k views

Slow Flask-SQLAlchemy query using association tables

I have two models in Flask-SQLAlchemy (Post and Comment) that have many-to-many relationship that is manifested in the third model (post_mentions): ...
3
votes
1answer
2k views

Applying dynamic filters to a SQL query using Python conditional expressions

I wrote this piece of code to eliminate the need for multiple if then statements based on the filters from the incoming REST request. If the request has category ...
3
votes
1answer
946 views

Generating string primary keys with sequence in SQLAlchemy

I need improvement on solution to the following problem: Generating random string keys in SQA is relatively simple, something like: ...
3
votes
0answers
33 views

Code organization: interacting with SQLAlchemy from inside class

I don't like the way my code is written, but at the moment, I don't see, how I should do it better. I have a class (let's say MyInvoiceType), which needs to save data to preexisting database. The ...
3
votes
0answers
67 views

Loading into a target table

Today I tried Bonobo + SQLAlchemy (for the first time), so it's bound to be full of bad practices. However, this is working code. I'm hoping for some feedback to for doing it correctly. I started out ...
3
votes
0answers
254 views

Flask-SQLAlchemy model structure

I'm seeking a review of my Flask-SQLAlchemy model structure, particularly adherence to DB best practices, such as avoiding duplication, etc. The models represent the relations between Departments, ...
3
votes
0answers
130 views

Constructing queries with SQLAlchemy based on search parameters

I have an app where the user can search for items in my database by entering a set of information, then the server receives it and for each option it queries the database, and stores the result in a ...
3
votes
0answers
882 views

Simple Payment System Flask App

Can I please get some reviews and suggestions? This is what this app does: It picks user login from Users table and compare it with the post in the login ...
3
votes
0answers
234 views

Implementing Flask create_app function with SqlAlchemy

I have a simple Flask app that realises rest-api with SQLAlchemy. I have written this create_app function: views.py ...
2
votes
1answer
58 views

SQLAlchemy code for calling parameters

I'm using the following function to process API parameters for an specific endpoint. Using SQLAlchemy and Flask, I want to get feedback in terms of simplifying calling SQL code and nested statements. ...
2
votes
1answer
172 views

SQLite database for a micro/tumble blog application

I'm creating a personal website where, among other things, there is a blog, or a "microblog" (I'm still not sure how to define the two), where I will be writing articles and having users, who will ...
2
votes
1answer
572 views

Insert or update a user in database

The code uses SQLAlchemy Core. However, what I want to know is if writing code in this pattern is recommendable. ...
2
votes
1answer
130 views

SqlAlchemy model for users and timezones

I have a following schema, I would like to query user and all timezones belongs to it including timezone name. Could you please validate if my schema constructed correctly and most efficient way? <...
2
votes
1answer
455 views

Saving items to database w/ sqlalchemy

Can someone please review my code? I'm saving a hotel rate to a database. I want to save the rate twice, one field will update with every new rate, and one field will contain the rate that was found ...
2
votes
1answer
1k views

Utility Class for CRUD Operations in a Flask App

I'm new to Flask and Python and am trying to sort out the most pythonic way to modularize my utilities. I have models.py which have my sqlalchemy models and ...
2
votes
0answers
36 views

Saving OAuth2 credentials to database with SQLAlchemy

I'm writing web application that uses Google Proximity Beacon API to interact with beacon data. In order to access that data, I need to grant access to use beacons' information for my web application ...
2
votes
0answers
115 views

REST backend app script for doing CRUD transactions

As a side project, I am working on Tiddly which is a simple Python(Flask) based app for a generic REST backend that could be used for CRUD transactions on any kind of database (using ...
2
votes
0answers
444 views

Structure of database model for a Flask project

I'm working on a project with Flask and I'm trying to follow Miguel Grinberg's Flask tutorial as closely as possible while creating what I need for my own project. Overall, how does it look? Miguel's ...
1
vote
1answer
317 views

Get json format from sqlalchemy class

I have written a small tool to generate a json file from sqlalchemy models files to automate the tedious procedure of writing all the sql raws in a json format. The script works, but there are few ...
1
vote
1answer
69 views

Add user to a database and perform relevant checks

Below is a function that adds a new user to the database using their email and password. I am using Flask and SQLAlchemy. ...
1
vote
0answers
47 views

Setting up user models with Flask-SQLAlchemy

I've recently come across SQLAlchemy, and as I had just been attempting to code something very similar to it, I think it's amazing. I've started on a new website, ...
1
vote
0answers
697 views

Parse query filter expression from request URL

I am building a backend APi for which I need to extract query filters from request URL of following pattern: ...
0
votes
0answers
49 views

Flask database design for a social media site like Twitter

This is a mysql database that is created through sqlalchemy. I really don't want to rewrite all of it in sql code, but the code should be understandable if you know a tiny bit of MySQL. I am ...