I currently have a supplier table and now I want to store the regions served by each supplier. As a first thought, I made my supplier model like this : Does this seem to be a good pattern? Especially for queries to filter suppliers by region served etc. Is this solution still reliable if in the future I want to
Tag: orm
SQL how do I sum up a has many relationship
So I have the following table, I managed to join users and membership tables just fine with a left join however I’ve been unsuccessful at summing up the individual customers’ total. Here’s my code, the one-to-one associations seem to be doing fine however the summing up of the total seems to not display, what am I doing wrong? is there
Is it possible to delete last n records of a django model in one/minimum database query?
I’m trying to delete last 10 records of Task table/model in django but I’m unable to do that in one query. Above code gives me error AttributeError : ‘list’ object has no attribute ‘delete’. If I make a loop and then use .delete() on each object of that list then it will call db n times which I don’t want,
Is it possible to omit FieldID in struct when using gorm?
Looking at an example from their documentation: CompanyID field seems rather redundant. Is it possible to get rid of it using some tags on Company field instead? Answer Changing User definition like this did the trick:
What is the default limit for auto generated primary Column(Integer) in SQLAlchemy with FastAPI and MYSQL?
Currently, I’m using Python’s fastAPI with SQLAlchemy and MYSQL. I’ve defined an auto-generated primary column as shown below. What’s the maximum number that this column can hold? Currently, the DB grows by 10k records per day, and I clear 70% of it on the weekends. The number of records will always stay constant, but I want to know the maximum
How to use variable column name in filter in Django ORM?
I have two tables BloodBank(id, name, phone, address) and BloodStock(id, a_pos, b_pos, a_neg, b_neg, bloodbank_id). I want to fetch all the columns from two tables where the variable column name (say bloodgroup) which have values like a_pos or a_neg… like that and their value should be greater than 0. How can I write ORM for the same? SQL query is
Unexpected result in WHERE clause on AI ID field
I have a table which’s name is users in my MySQL database, and I am using this DB with Ruby on Rails application with ORM structure for years. The table has id field and this field is configured as AI (auto-increment), BIGINT. Example of my users table; The problem I am facing is when I execute the following query I
Spring Data Jpa to get data which doesn’t have entity representation
I’m trying to find the best way to map my data on ORM. I have a query which gets me data from MySQL database which look like What would be the most optimal way to get these data with Spring boot and Spring data?? Should I use @Query annotation and execute this or somehow create entities for Equipment and Devices
Model hierarchy in Django [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question Sorry for the long text Models are given: User Hierarchy class Hierarchy (Model): There are users, they can invite each
Orderby on multiple columns using typeorm
In my application, I am using MySQL and typeorm and want to do orderBy using multiple columns. I searched so many places for it but did not get any solution. Example: I have two columns in a table user and respective User Entity ________________________________________ | id | name | createDate | createdTime | —————————————- | 1 | Sai | 2020-12-12