postgresql

How to omit certain parts of a SQL query

How to omit certain parts of a SQL query Question: Disclaimer that I’m highly aware there’s a better way to word the question, if someone wants to suggest a better way I’d be happy to change it I’ve been working with DynamoDB for the past 4 years and now I’m switching one of my tables …

Total answers: 1

airflow PostgresOperator report number of inserts/updates/deletes

airflow PostgresOperator report number of inserts/updates/deletes Question: I’m exploring replacing our home-build SQL file orchestration framework with apache airflow. We currently have extensive logging on execution time, history and number of records INSERTED/UPDATED/DELETED. The first two are supported by Airflow standard logging, however, I could not find a way to log the resulting counts of …

Total answers: 1

The first field in the models.py not created, how to fix it? (django)

The first field in the models.py not created, how to fix it? (django) Question: I have written two classes in models.py (Django): class Name_tickers(models.Model): ticker = models.CharField(max_length = 32) name = models.CharField(max_length = 100) def __str__(self): return self.ticker class Close_stock(models.Model): date = models.DateField(), tiker_name = models.ForeignKey(Name_tickers, on_delete=models.CASCADE), price = models.DecimalField(max_digits=15, decimal_places=5) But was created: migrations.CreateModel( …

Total answers: 1

"Argument error" in Python using sqlalchemy

"Argument error" in Python using sqlalchemy Question: I’m trying to fetch data from database using sqlalchemy in but i get the following error sqlalchemy.exc.ArgumentError: Column expression, FROM clause, or other columns clause element expected, got [Table(‘params’, MetaData(), Column(‘paramID’, Integer(), table=, primary_key=True, nullable=False), Column(‘item’, String(), table=), Column(‘value’, Float(), table=), schema=None)]. Did you mean to say select(Table(‘params’, …

Total answers: 1

Real time notifications from a Postgres function

Real time notifications from a Postgres function Question: I am trying to execute a function in Postgres which contains a number of Raise statements for debugging and info. While I am able to connect to DB and get raise statements using conn.notices(). These are not printed to python console on a real time basis and …

Total answers: 1

Docker Compose with Django and Postgres Fails with "django.db.utils.OperationalError: could not connect to server:"

Docker Compose with Django and Postgres Fails with "django.db.utils.OperationalError: could not connect to server:" Question: I am trying to run my django/postgres application with docker compose. When I run docker compose up -d I get the the following logs on my postgres container running on port 5432: 2023-02-18 00:10:25.049 UTC [1] LOG: starting PostgreSQL 13.8 …

Total answers: 1

Join 3 tables in postgresql on different objects

Join 3 tables in postgresql on different objects Question: I have a dataframe with 3 tables, lets call them People, Event, Outcome. The setup for these tables would look like this: Name has: ID, Name, Age; Outcome has: ID, EventID, EventTime and OutcomeID; Event has: EventID, EventState, EventDate, EventTemp. I need to run a query …

Total answers: 1

Reading csv data into a table in postgresql via INSERT INTO with Python

Reading csv data into a table in postgresql via INSERT INTO with Python Question: I have a postgresql table created in python that I need to then populate with data from a csv file. The csv file has 4 columns and a header row. When I use a for loop with INSERT INTO it’s not …

Total answers: 1

Sqlalchemy is slow when doing query the first time

Sqlalchemy is slow when doing query the first time Question: I’m using Sqlalchemy(2.0.3) with python3.10 and after fresh container boot it takes ~2.2s to execute specific query, all consecutive calls of the same query take ~70ms to execute. I’m using PostgreSQL and it takes 40-70ms to execute raw query in DataGrip. Here is the code: …

Total answers: 1

How to use a Postgreql Boolean value as a parameter in a python if statement?

How to use a Postgreql Boolean value as a parameter in a python if statement? Question: I have been trying to create a python function that will use a select statement that will return a single Boolean value from my postgres database and then use it in a python if statement. I have found out …

Total answers: 1