0

I am trying connect to my postgress database using SQLAlchemy. I was working fine yesterday (01/27/22). Now I get the following error:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) FATAL: role "wsb" does not exist

Only the user does exist.

                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 wsb       | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 wsb2      |                                                            | {}

As you can see I tried making another user "wsb2", but that didn't work either. Below is my script:

db_string = "postgresql://wsb:wsb@localhost:5432/wsb"

db = create_engine(db_string)
meta = MetaData()

submissions_table = Table('wsb_submissions', meta,
                          Column('index', INTEGER),
                          Column('submission_id', TEXT),
                          Column('title', TEXT),
                          Column('created', TIMESTAMP),
                          Column('author', TEXT),
                          Column('ticker_mentioned', TEXT),
                          Column('subreddit', TEXT),
                          Column('emotes', ARRAY(TEXT)),
                          Column('rocket_emotes', INTEGER)
                          )

comments_table = Table('wsb_comments', meta,
                       Column('index', INTEGER),
                       Column('comment_id', INTEGER),
                       Column('body', TEXT),
                       Column('created', TIMESTAMP),
                       Column('author', TEXT),
                       Column('rocket_emotes', INTEGER),
                       Column('subreddit', TEXT),
                       Column('emotes', ARRAY(TEXT)),
                       Column('submission_key', TEXT)
                       )
db.connect()

also here is my Dockerfile:

FROM postgres:13.2

ENV POSTGRES_PASSWORD=wsb
ENV POSTGRES_USER=wsb
ENV POSTGRES_DB=wsb

COPY wsb.sql /docker-entrypoint-initdb.d/
EXPOSE 5432

1 Answer 1

-1

So this worked for me. I am relatively new to operating systems, so idk if there are any consequences that I'm unaware of.

my solution: in terminal run:

lsof -i:5432
sudo kill [PID]

then rebuild the image and restart the container.

3
  • Thanks for the input. What would have been the better way? And how can I snuff out data corruption? Jan 30, 2022 at 18:03
  • You are in no danger if you never use kill -9 on the postmaster. Plain old kill is the right thing - it will shut down PostgreSQL properly. If you fix that, I'll un-downvote your answer, but the way it is it is a public danger. The best solution would of course to figure out what is going on. Jan 30, 2022 at 18:39
  • ok, I'll change it. thanks for the clarification. Jan 30, 2022 at 21:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.