Re: [GENERAL] Importing SQLite database - Mailing list pgsql-general

From Adrian Klaver
Subject Re: [GENERAL] Importing SQLite database
Date
Msg-id 66531f49-fbb8-11fd-4c4e-d097d406349f@aklaver.com
Whole thread Raw
In response to Re: [GENERAL] Importing SQLite database  (Igor Korot <ikorot01@gmail.com>)
Responses Re: [GENERAL] Importing SQLite database
List pgsql-general
On 12/08/2016 04:47 PM, Igor Korot wrote:
> Hi, guys,
>

>
> This is the result of running "SQL shell":
>
> [code]
> Last login: Thu Dec  8 19:46:41 on ttys001
> Igors-MacBook-Air:~ igorkorot$ /Library/PostgreSQL/9.1/scripts/runpsql.sh; exit
> Server [localhost]:
> Database [postgres]:
> Port [5432]:
> Username [postgres]:
> Password for user postgres:
> psql (9.1.24)
> Type "help" for help.
>
> postgres=#
> [/code]
>
> And this is the result of running "psql" command in Terminal:
>
> [code]
> Igors-MacBook-Air:dbhandler igorkorot$ psql -U postgres -d postgres
> psql: could not connect to server: No such file or directory
>     Is the server running locally and accepting
>     connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
> [/code]
>
> Any idea why I can't connect?

Because you are trying a local socket connection and psql cannot find
the socket. Not sure where the Apple install would create it, so cannot
help there. However if you replicate the connection that worked with SQL
shell you should be able to connect. So:

psql -U postgres -d postgres -h localhost

FYI, not having the -h tells psql to connect using a socket.

>
> Also is PostgreSQL is set initially to use "Transaction-mode"? I.e.
> every SQL command should end up with COMMIT?

That is more of a client side attribute. For psql the default is to
enclose every command in a transaction, so no explicit BEGIN/COMMIT is
needed:

https://www.postgresql.org/docs/9.5/static/app-psql.html
"AUTOCOMMIT

     When on (the default), each SQL command is automatically committed
upon successful completion. To postpone commit in this mode, you must
enter a BEGIN or START TRANSACTION SQL command. When off or unset, SQL
commands are not committed until you explicitly issue COMMIT or END. The
autocommit-off mode works by issuing an implicit BEGIN for you, just
before any command that is not already in a transaction block and is not
itself a BEGIN or other transaction-control command, nor a command that
cannot be executed inside a transaction block (such as VACUUM).

         Note: In autocommit-off mode, you must explicitly abandon any
failed transaction by entering ABORT or ROLLBACK. Also keep in mind that
if you exit the session without committing, your work will be lost.

         Note: The autocommit-on mode is PostgreSQL's traditional
behavior, but autocommit-off is closer to the SQL spec. If you prefer
autocommit-off, you might wish to set it in the system-wide psqlrc file
or your ~/.psqlrc file.

"

>
> Thank you.
>



--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: [GENERAL] Would like to below scenario is possible for gettingpage/block corruption
Next
From: Steve Litt
Date:
Subject: Re: [GENERAL] Looking for an online mentor