Questions tagged [sqlalchemy]

Use this tag for the eponymous Python SQL toolkit and Object Relational Mapper.

Filter by
Sorted by
Tagged with
0
votes
0answers
15 views

PostgreSQL & Pandas DF: is it possible to update a selection of data of a PostgreSQL db with a DF w/o impacting other entries?

I have a PostgreSQL database, which I interact with using SQLAlchemy in Python. The database contains daily price data (including non-working days), starting from Jan-2005; the date column is the ...
0
votes
1answer
574 views

convert SQL query to SQLAlchemy query [closed]

I am having a lot of trouble in converting the below SQL query to SQLAlchemy query. Please help: insert into conform_layer (unique_no,key_name,value_name) SELECT id, key, value FROM (select ...
0
votes
1answer
3k views

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=...
0
votes
0answers
51 views

How to “lock” a table for select

I have a table called assignments. A user will request an assignment from an API endpoint. I need to ensure that an assignment can only be handed to one user. There will be multiple users requesting ...
0
votes
1answer
506 views

Converting a date to a datetime in MySQL

I'm supposed to add time to a date field. We use MySQL with python3, alembic and sqlalchemy. Now I've written a conversion program. It is my first program of such a kind. I'm not certain how it will ...
1
vote
0answers
602 views

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("...
0
votes
1answer
2k views

Why are my queries taking so long? [closed]

In order to quickly calculate some features for later calculations I have attempted to store a table that allows looking up distances between locations that have been pre-calculated. I am using Python ...
1
vote
0answers
141 views

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 ...
2
votes
1answer
366 views

Database relationship inheritance [closed]

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 ...
3
votes
0answers
327 views

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, ...
0
votes
1answer
239 views

Use of MySQL trigger to insert row's week number

I have a table of orders in a MariaDB database that currently has a datetime column. For the dashboard I am building for this database, I have a statistic I would like to display which is "Orders This ...
3
votes
3answers
2k views

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' ...