Re: psql on Mac - Mailing list pgsql-novice
From | Ozan Kahramanogullari |
---|---|
Subject | Re: psql on Mac |
Date | |
Msg-id | CAPiqqL=S8+ns8zGwjSfCR24hq8GEsd4Uj=XsNEw+rJ2Y=oY=OA@mail.gmail.com Whole thread Raw |
In response to | Re: psql on Mac (Tom Lane <tgl@sss.pgh.pa.us>) |
Responses |
Re: psql on Mac
Re: psql on Mac |
List | pgsql-novice |
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 <tgl@sss.pgh.pa.us> wrote:
Ozan Kahramanogullari <ozan.kah@gmail.com> 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
pgsql-novice by date: