Re: psql on Mac

Ozan Kahramanogullari <[email protected]>
Newsgroups gmane.comp.db.postgresql.novice
Message-ID <CAPiqqL=S8+ns8zGwjSfCR24hq8GEsd4Uj=XsNEw+rJ2Y=oY=OA@mail.gmail.com>
Well, I took the default settings when I was installing PostgreSQL. And,
yes, I ran the "show" commands on the command line console; it gave an
error. I ran the "show" commands on the psql prompt that delivered nothing,
no error as well.

I am open to any suggestions, including reinstalling everything from
scratch, if there are any precise instructions.

I am not ruling out that I am doing something wrong. Though, I was
convinced that following simple instructions would not be that hard. I have
tried to provide all the information in the previous emails. I am puzzled
myself; after all, this is quite a standard platform (Mac) and all I am
trying to do is access some SQL database with a python file (see below).

 Cheers,
Ozan

######## SQL stuff ###########

CREATE TABLE flights (
    id SERIAL PRIMARY KEY,
    origin VARCHAR NOT NULL,
    destination VARCHAR NOT NULL,
    duration INTEGER NOT NULL
);

INSERT INTO flights (origin, destination, duration) VALUES ('New York',
'London', 415);
INSERT INTO flights (origin, destination, duration) VALUES ('Shanghai',
'Paris', 760);
INSERT INTO flights (origin, destination, duration) VALUES ('Istanbul',
'Tokyo', 700);
INSERT INTO flights (origin, destination, duration) VALUES ('New York',
'Paris', 435);
INSERT INTO flights (origin, destination, duration) VALUES ('Moscow',
'Paris', 245);
INSERT INTO flights (origin, destination, duration) VALUES ('Lima', 'New
York', 455);

######## python file ##########
import os

from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker

engine = create_engine(os.getenv("DATABASE_URL"))
db = scoped_session(sessionmaker(bind=engine))

def main():
    flights = db.execute("SELECT origin, destination, duration FROM
flights").fetchall()
    for flight in flights:
        print(f"{flight.origin} to {flight.destination}, {flight.duration}
minutes.")

if __name__ == "__main__":
    main()
##############################

On Wed, 24 Oct 2018 at 11:42, Tom Lane <[email protected]> wrote:

> Ozan Kahramanogullari <[email protected]> writes:
> > Hi Tom, Thank you! I copied and pasted the content of your pg_hba file as
> > it is. Then, I rebooted my computer.  There is only one installation of
> > postgreSQL, so there is only such file. It is in the folder
> > "/Library/PostgreSQL/10/data".
>
> I'm a bit suspicious of that, first because that doesn't seem like a
> normal place to put Postgres, and second because it's not working for
> you so there must be *something* incorrect in what you've told us.
> Did you confirm the server's notion of where pg_hba.conf is via
> "show" and/or the view?
>
>                         regards, tom lane
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.