database

Python Export table from postgres and import to another postgres using

Python Export table from postgres and import to another postgres using Question: I have 2 postgres databases with same schema but in 2 different schemas. I am writing a python script with a goal to export data partially from one of the tables and import the result to the same table but in a different …

Total answers: 1

How to code unique constraint per parent ForeignKey in Django model?

How to code unique constraint per parent ForeignKey in Django model? Question: Here’s my code: from django.db import models class Parent(models.Model): name = models.CharField(max_length=50, unique=True) def __str__(self): return str(self.name) class Child(models.Model): parent = models.ForeignKey(Parent, on_delete=models.CASCADE) name = models.CharField(max_length=50, unique=True) def __str__(self): return str(self.name) Parents in my database: Rogan Smith Doe In admin dashboard: First, I …

Total answers: 1

Convert DataFrame with 5*5 grid of choice with string of ranges

Convert DataFrame with 5*5 grid of choice with string of ranges Question: Score and Score2 column ranges are not working with df.eq(s) because of the input as ranges. Default values:- import pandas as pd df = pd.DataFrame({‘Score’: [‘>285’, ‘285-280’, ‘280-275’, ‘275-260’, ‘<260′],’Grade1’: [‘A1’, ‘A2’, ‘A3’, ‘A4’, ‘A5′],’Score2’: [‘>270’, ‘270-260’, ‘260-250’, ‘250-200’, ‘<200′],’Grade3’: [‘D1’, ‘D2’, ‘D3’, …

Total answers: 1

Python and SQLite: insert into table by input

Python and SQLite: insert into table by input Question: enter image description here I am doing this but it still gives me this Error I am trying to insert data by input into the table Asked By: Suliman || Source Answers: Try this: cr.execute(f"INSERT INTO Family VALUES(‘{name}’,{age},'{Hobby}’)") Answered By: user56700 Python example to insert a …

Total answers: 2

Python Realtime Database (Google Firebase) sending Integer instead of JSON file to servers

Python Realtime Database (Google Firebase) sending Integer instead of JSON file to servers Question: While coding in python in many projects, I’ve encountered the error of firebase’s RealTime Database sending an integer instead of the json file. I’ve checked and I’ve imported the JSON packages, loaded the correct files (etc) Here is the following code: …

Total answers: 1

How to filter an input to search a database in python

How to filter an input to search a database in python Question: I’m an intermediate python coder, but i’m still somewhat new to it. I just started using json files (kind of like a database), and my most recent projects was to use the nba database (https://data.nba.net/prod/v1/today.json) for a user input that tells about an …

Total answers: 1

Why value is not Inserting in the database using django

Why value is not Inserting in the database using django Question: I want to insert value in the database from checklist. it print me the value but does’t show anything in the database. it’s empty. sample output what I’m getting if ISMS(which is on the third place) is checked [00100] the zero changes accordingly but …

Total answers: 1

How to select the given case statement as column

How to select the given case statement as column Question: I want to query the table after giving case statement/ %sql SELECT user_id, user_name, email, CASE WHEN user_name = ‘ruo’ THEN ‘No’ WHEN user_name = ‘ruoman’ THEN ‘Yes’ else ‘Other’ END AS New_Data FROM Pes %sql SELECT user_name from Pes where New_Data = ‘Yes’ –> …

Total answers: 1

Use LIMIT on two tables with an Inner Join

Use LIMIT on two tables with an Inner Join Question: The following SQL code works fine. It has the purpose of displaying all the products ordered by each user and sorting them by products in a descending manner. The problems occur when I try to limit the display of customers and their related products, so …

Total answers: 1

django.db.backends.postgresql error when try to makemigrations my django project

django.db.backends.postgresql error when try to makemigrations my django project Question: I am trying to switch my Django database from SQLite3 to PostgreSQl, so I follow many tutorials to install and setup Postgres with Django project. I did the following: pip install psycopg2, pip install psycopg2-binary and I modified the settings.py like that: DATABASES = { …

Total answers: 3