In Django app, I’m using Postgres DB. I have two tables where one of them has 76 million records and the other 8.2 million. I have created a new migration file where in I’m adding a new column to a table in an app and setting default value to 0. My database is hosted on Ubuntu EC2 instance which has
Tag: postgresql
no such table: wagtailcore_site
I’m hosting two websites on ubuntu server and both having postgresql, the first one is working prefect but the second give me this error no such table: wagtailcore_site Request Method: GET Django Version: 2.2.10 Exception Type: OperationalError Exception Value: no such table: wagtailcore_site Exception Location: /home/project2/.venv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 383 Python Executable: /home/project2/.venv/bin/python3.7m Python Version: 3.7.3 database settings for first
Django model filter targeting JSONField where the keys contain hyphen / dash
I am trying to apply a model filter on a JSONField BUT the keys in the JSON are UUIDs. So when is do something like… … I get a compile error. The hyphens in the UUID are the issue. Any clues if there is an escape char or another behaviour to use? My database is PostgreSQL. Update 1 – now
Best method for sending large pandas dataframe to SQL database?
I have a pandas dataframe which has 10 columns and 10 million rows. I have created an empty table in pgadmin4 (an application to manage databases like MSSQL server) for this data to be stored. However, when running the following command: It takes a very long time in order to run and often crashes my jupyter kernel given that the
How to insert today’s date in SQL select statement using python?
I’m trying to send today variable into SQL but it is not working. Answer You don’t have to compute today’s date in Python. Just use the PostgreSQL function CURRENT_DATE:
Sharing a postgres connection pool between python multiproccess
I am trying to use psycopg2’s connection pool with python’s multiprocess library. Currently, attempting to share the connection pool amongst threads in the manner described above causes: The following code should reproduce the error, which the caveat that the reader has to set up a simple postgres database. What I have already tried: Having each process open and close its
Django change wrong column name in DB
in my Database (psql) I’ve got a table named offers_offer and inside that there is an column named offer_name, which is wrong, because it should actually be just name. I don’t know why it has this name, but due to this I can’t load any fixtures or create a new object, because I always receive the error that name wasn’t
Python Subprocess Module | Postgres pg_dump with password
I have a database that I want to back up with my a python code. I tried to base my code from the code in this discussion that uses the subprocess module and pg_dump. My problem now is that I have to manually type in the password to get the backup file. I read somewhere that doing a .pgpass but
Django test error: Column does not exist
Postgresql, Django 2.0, Python 3.6.4 After running a migration that changed the name of a field desktop_pay to simply pay, I’m getting an error when running manage.py test saying the column pay does not exist. Here’s the migration: Here’s the error: If I start a psql prompt, though, I can clearly see that the column does exist, at least in
Exporting a PostgreSQL query to a csv file using Python
I need to export some rows from a table in a PostgreSQL database to a .csv file using a Python script: But when I run the script I get this: Does anyone know what can be wrong or give me a tip about? Answer The copy is not an SQL command, it is a command specific for the Postgres terminal