Questions tagged [sqlalchemy]

The popular Python package. If your question is about python coding, ask it on StackOverflow. Questions with this tag should focus on database code or the DB engine.

SQLAlchemy is a Python SQL toolkit and Object Relational Mapper.

40 questions
9
votes
3 answers

Performance of count(*) in subquery

Suppose we have the following queries: 1. SELECT COUNT(*) FROM some_big_table WHERE some_col = 'some_val' 2. SELECT COUNT(*) FROM ( SELECT * FROM some_big_table WHERE some_col = 'some_val' ) Does any of the previous queries perform better?…
5
votes
2 answers

How to set a auto-increment value in SQLAlchemy?

This is my code : class csvimportt(Base): __tablename__ = 'csvimportt' #id = Column(INTEGER, primary_key=True, autoincrement=True) aid = Column(INTEGER(unsigned=True, zerofill=True), Sequence('article_aid_seq',…
Farhaan Patel
  • 51
  • 1
  • 1
  • 8
3
votes
0 answers

SELECT query blocking writes in postgresql

We have a web application that sends emails with a queue worker. Before an email is sent we write to a table: INSERT INTO user_email (user_id, email_key, sent_at) VALUES ( 175413579283955991, 'reminder-2017-07-06', …
2
votes
2 answers

Operational Error on MySQL AWS RDS Instance

The heading pretty much describes it all, here are some more information on the Amazon RDS I am using. Engine: MySQL Community 8.0.28 Class db.r6g.large Multi-AZ no. The data volume is very small, not even a few megs, as I am just doing some PoC to…
Della
  • 73
  • 5
2
votes
1 answer

How to efficiently store impressions in db?

For my flask app I need to track impressions, clicks on images. The current implementation that I have is impressions table where I store impression ip, useragent, geo location and all the relationships that I would like to have. So every impression…
martinktm
  • 21
  • 1
2
votes
1 answer

Database relationship inheritance

I have a vehicle sales store. In my store I sale many kind of vehicles for example cars and boats. And I would like to keep track of the sales. My vehicles has some attributes as: Arrive on store at (a date) Brand Model Color Type (is a car or is…
Lin
  • 123
  • 3
1
vote
0 answers

Aurora PostgreSQL Severe Performance Degradation Under Concurrent Load

Environment: Database: AWS Aurora PostgreSQL ORM: SQLAlchemy API Framework: Python FastAPI Issue: I'm experiencing significant query performance degradation when my API receives concurrent requests. I ran a performance test comparing single…
1
vote
1 answer

UPDATE incredibly slow on small PostgreSQL query - EXPLAIN ANALYZE causes it to hang

I'm trying to debug a very slow UPDATE query in one of my tables. The table name is beepers. It has 2486 rows and weighs 1204 MB. It has 18 columns and two indices: one on id and the other on friendly_name (a string with a legible name, i.e.…
R. Gosman
  • 11
  • 3
1
vote
0 answers

SQL connection error in python webapp: "pandas.io.sql.DatabaseError: Execution failed on sql"

I have built a Webapp with python flask, that reads and writes to SQL tables. Typically in the morning, I receive an error regarding SQL query execution that looks like this (see logs snippet below). I'm quite new to web development and everything…
Liam
  • 11
  • 1
  • 2
1
vote
1 answer

Unable to convert a table to hypertable due to unique index error

I am creating a table using Flask SQL Alchemy as follows: class Price(db.Model): __tablename__ = "prices" id = db.Column(db.Integer, primary_key=True) country_code = db.Column(db.String(2), nullable=False) value =…
some_programmer
  • 113
  • 1
  • 8
1
vote
1 answer

Storing many pandas DataFrames in SQLite with metadata

I need some help with designing a database. My aim is to persistently store a number of pandas DataFrames in a searchable way, and from what I've read SQLite is perfect for this task. Each DataFrame contains about a million rows of particle…
smcs
  • 113
  • 5
1
vote
1 answer

How to Bulk Insert sqlalchemy subclasses

I am trying to bulk insert SQL-Alchemy Subclasses into the parent table and their respective tables ie fruits tables -> Apple Table and so I insert a table of APPLE and it will insert both the row into the fruits table then give me the id of the row…
Nilesh Kesar
  • 121
  • 5
1
vote
0 answers

UUID default value on PSQL

I'm creating my database tables inside a flask application via SQLAlchemy. According to this answer, my code should look like this: id = db.Column(db.CHAR(36), primary_key=True, server_default=str("uuid_generate_v4()")) which, after migrations and…
codeninja
  • 129
  • 3
  • 7
1
vote
0 answers

Multiple many-to-many database relations

SO told me to ask here, so this is just copy-pasted from over there We're making a database of anime. Every anime can be listed as having been made by an arbitrary number of studios, and every studio can have made an arbitrary number of anime. The…
1
vote
2 answers

How to cache queries in sqlalchemy just like I do it in mysql by using SQL_CACHE keyword?

I want to cache sqlalchemy, I have discovered that using keyword SQL_CACHE in mysql can be helpful in caching queries on demand. But how do I do it in sqlalchemy? Is it possible?
1
2 3