postgresql

RemovedIn20Warning when inserting a record using engine.connect()

RemovedIn20Warning when inserting a record using engine.connect() Question: I am new to SQLAlchemy. I am trying to execute a simple insert statement, but I get a "removed In 2.0" warning. from sqlalchemy import (MetaData, Table, Column, Integer, Numeric, String, ForeignKey, create_engine) metadata = MetaData() cookies = Table(‘cookies’, metadata, Column(‘cookie_id’, Integer(), primary_key=True), Column(‘cookie_name’, String(50), index=True), Column(‘cookie_recipe_url’, …

Total answers: 1

FastAPI and PostgreSQL in docker-compose file connection error

FastAPI and PostgreSQL in docker-compose file connection error Question: This question has been asked already for example Docker: Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? but I still can’t figure out how to properly connect the application to the database. Files: Dockerfile FROM python:3.10-slim WORKDIR /app COPY …

Total answers: 1

Get rid of characters when writing a dataframe to postgress

Get rid of characters when writing a dataframe to postgress Question: I have a large script that saves data to a postgres database. Tell me how can I get rid of [‘ and ‘]. I need the data in the storage to be saved without these characters total.to_csv("C:/Users/…/total_type19.csv", index = False, sep =’;’) conn5 = …

Total answers: 2

How to change column datatype when loading csv in postgresql

How to change column datatype when loading csv in postgresql Question: I have a big script, the result is that the data is stored in a dataframe and then in csv. Then csv is opened and written to PostgreSQL. But there is a problem that the data type of one column is int4, and after …

Total answers: 2

SQL placeholder using character versus numeric values

SQL placeholder using character versus numeric values Question: I am trying to get more familiar with placeholders to to run SQL commands from python, but cannot successfully pass character commands. Here I describe a simplified solution that will be scaled up. In python I can create a basic SQL query using a placeholder sql = …

Total answers: 1

How to update postgres array on Python

How to update postgres array on Python Question: I selected column "user_list" in ‘users’ table and fetched to a python variable called "u_list". I appended ‘item’ in it and tried to update "user_list", but got a lot of errors. I tried searching on stackoverflow, but nothing helped. code: cursor.execute(f’SELECT user_list FROM users WHERE id=442392434899681280′) u_list …

Total answers: 1

PostgreSQL : ERROR: syntax error at or near "("

PostgreSQL : ERROR: syntax error at or near "(" Question: I started to learn PSQL. I have a question how to solve this problem, in my opinion the code should be ok but BD says otherwise ;). Can someone help me with this. Thank you in advance. The code is from a terminal on Ubuntu …

Total answers: 1

use mutliple foreign keys

use mutliple foreign keys Question: I have a table with a composite primary key, these two columns are then used as both primary and foreign key for another table, but I can not seem to create the relationship in sqlalchemy. I get the following error sqlalchemy.exc.AmbiguousForeignKeysError: Could not determine join condition between parent/child tables on …

Total answers: 1

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

cascade delete not being used sqlalchemy

cascade delete not being used sqlalchemy Question: I am getting the following error when I try to delete all entries from parent table sqlalchemy.exc.IntegrityError: (psycopg2.errors.ForeignKeyViolation) update or delete on table "parent" violates foreign key constraint "child_p_id_fkey" on table "child" DETAIL: Key (id)=(1) is still referenced from table "child". This is my code, and I have …

Total answers: 1