I wish to count the number of males and females in a specific city that the user chose. Here’s a gist of the .db file: example_table CODE AGE SEX CITY —- — — —- E101 …
Tag: python
Django, have model to be related to many instances of itself
I have a model: I want it to have a sub_industries field that will hold all of its sub industries, which should be instances of Industry model. I cannot be ManyToMany because each industry has only one parent industry. Answer You can add a ForeignKey to itself with: You can use NULL/None to express that an industry has no parent.
Multithreading to load data to SQL tables?
On a weekly basis, I run a Python script that migrates data from a PostgreSQL server to a Teradata server. One table at a time, this script: DROP/CREATEs the Teradata version of the table, pulls the new data from PostgreSQL, saves a copy of the table data as a CSV in a network drive (for business reasons), adds the data
sqlite3.OperationalError: ambiguous column name: views
Help! I try to update the select statement but it seems to not work here So, let me introduced my table Artists and Songs Note:I already inserted these table yet and, this is where I update SELECT statement and cause me an error This is the error So I decided to change from views to Songs.views and, it still gave
How to neglect timestamps when inserting date to MySQL database
I want to insert a date into MySQL table. But, even if I use strftime(), the timestamps are showing like 00:00:00. How can I get rid of it? Output: Answer Obviously the column Date has data type DATETIME or TIMESTAMP. If you don’t need the time part of the column, you should change the data type to DATE:
How can I use WHERE with multiple different columns?
Having trouble trying to query AND and OR in an SQlite3 statement. Is there a way where I can do something like WHERE section = ? AND LEVEL =? AND subj1 =? AND subj2=? AND subj3 =? From what I see in this particular line It won’t work because after ‘AND subj1 =?’ SQlite3 now chooses to select whatever subject
Cyrillic symbols in SELECT query PostgreSQL
I have a telegram bot (Aiogram, Python), which is connected to PostgreSQL database. If user enters a some username (in Cyrillic, Russian or Ukrainian), bot should return full information about this user, stored in database. The problem is: when bot making query to the database, with username for example “Сергій”, it returns nothing, although information exists in database. I found
Dropping the index column from DataFrame in a .csv file in Pandas
I have a python script here: and when I run it, it creates separate csv files that are formatted in sql. The output looks like this in generatedfile2: The rest of the files have this same format. Is there any way I can change my code to get rid of the “2” at the beginning of the code? It won’t
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
group by date and two different times in the same date in Sql
i want to select from my database the data that is BETWEEN to date and two different times in the same date but when I use the Sum in one of the variants it give me a wrong result i thnik that the …