Skip to content
Advertisement

Tag: postgresql

Kafka with python: How to send topic to postgreSQL?

I am urged to use Kafka with python. Moreover, I need to develop a very simple producer-consumer application that reads metrics from a device in real-time and then publishes them to a topic ‘metrics’ in Kafka. Then a consumer must subscribe to the ‘metrics’ topic and store those data to a postgreSQL database. I tried to draw the architecture here:

python psycopg2 select current_timestamp problem with timezone

I’m calling a simple select to obtain current timestamp with timezone with psycopg2 and it’s retrieving UTC time instead of my local time (-3). datetime.datetime(2021, 1, 13, 20, 49, 47, 931834, tzinfo=psycopg2.tz.FixedOffsetTimezone(offset=0, name=None)) In postgresql I’m doing: This retrieves (Argentina time -3): So this is correct, but in Python: Select method retrieves: So datetime object is comming with offset 0,

column “e” of relation “analysis_result” does not exist

connection to postgresql database has been connected successfully.but while executing below query i am getting some kind of error which looks like : column “e” of relation “analysis_result” does not exist LINE 1: INSERT INTO analysis_result(user_id,E,A,C,N,O,total) VALUES … i understand what is the error .i have to put each of E A C N O in quotes but while quoting

Python-Flask No response: After stayed active for one day

App description: I am using Python-Flask module with PostgreSql 12 as a REST API on a Web based application. There is a lot of request based heartbeat (JavaScript SetIntervals to send heartbeat almost for a every second and the CRUD operations for every user request on a small scale) and REST data (json data with responsed jsonify library of flask)

asyncpg.exceptions.DataError: invalid input for query argument $1: 217027642536 (value out of int32 range)

I’m working on a project that uses FastAPI alongside Pydantic and SQLAlchemy. I’m also using encode/databases to manage database connections. But for some weird reason, I get asyncpg.exceptions.DataError: invalid input for query argument $1: 217027642536 (value out of int32 range) anytime I try saving to the database. Here’s what my code looks like: database.py database_manager.py endpoints.py models.py services.py I can’t

How to upsert pandas DataFrame to PostgreSQL table?

I’ve scraped some data from web sources and stored it all in a pandas DataFrame. Now, in order harness the powerful db tools afforded by SQLAlchemy, I want to convert said DataFrame into a Table() object and eventually upsert all data into a PostgreSQL table. If this is practical, what is a workable method of going about accomplishing this task?

Advertisement