Обсуждение: Using md5 authentication

Поиск
Список
Период
Сортировка

Using md5 authentication

От
Philip Poloczek
Дата:
Hello,

I want to connect to my database using a md5 hash instead of the plain
password, so i changed the authentication method in the pg_hba.conf to
md5 instead of password.
example: i want to use '5f4dcc3b5aa765d61d8327deb882cf99' instead of
'password' in the login mask.

But until now i didn't get it working, i still can connect to the
database with the plain password but not with the corresponding md5
Hash. When i'am using the md5 hash i just get a FATAL error for password
authentication. I used pg_ctl to reload the pg_hba.conf and also
restarted the server.

Also the md5 hash which is saved for the users in the database differs
from my created ones for that specific password. I read that the
passwords are salted before encrypted with a part of the usernames? But
even if i use these md5 hashes as password input, i can not connect and
get a FATAL error.

BTW is it possible to use SHA-1 encrypted passwords with postgresql?

I'am currently using postgresql 8.4.

pg_hba.conf
local   all         all                                md5
host    all         all         127.0.0.1/32           md5

Best recards,
pp


Re: Using md5 authentication

От
Athanasios Kostopoulos
Дата:
From the manual:
"The password-based authentication methods are md5 and password. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively."

so you still have to specify the password and not the hash of it in your .pgpass or manual connection string.


On Wed, Jul 31, 2013 at 9:17 AM, Philip Poloczek <Philip.Poloczek@dlr.de> wrote:
Hello,

I want to connect to my database using a md5 hash instead of the plain password, so i changed the authentication method in the pg_hba.conf to md5 instead of password.
example: i want to use '5f4dcc3b5aa765d61d8327deb882cf99' instead of 'password' in the login mask.

But until now i didn't get it working, i still can connect to the database with the plain password but not with the corresponding md5 Hash. When i'am using the md5 hash i just get a FATAL error for password authentication. I used pg_ctl to reload the pg_hba.conf and also restarted the server.

Also the md5 hash which is saved for the users in the database differs from my created ones for that specific password. I read that the passwords are salted before encrypted with a part of the usernames? But even if i use these md5 hashes as password input, i can not connect and get a FATAL error.

BTW is it possible to use SHA-1 encrypted passwords with postgresql?

I'am currently using postgresql 8.4.

pg_hba.conf
local   all         all                                md5
host    all         all         127.0.0.1/32           md5

Best recards,
pp


--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice


classmarkets GmbH | Schumannstraße 6 | 10117 Berlin | Deutschland
Tel: +49 (0)30 56 59 001-0 | Fax: +49 (0)30 56 59 001-99 | www.classmarkets.com

Amtsgericht Charlottenburg HRB 111815 B | USt.Id.Nr: DE 260731582
Geschäftsführer: Veit Mürz, Fabian Ströhle

Diese Nachricht (inklusive aller Anhänge) ist vertraulich. Sie darf ausschließlich durch den vorgesehenen Empfänger und Adressaten gelesen, kopiert oder genutzt werden. Sollten Sie diese Nachricht versehentlich erhalten haben, bitten wir, den Absender (durch Antwort-E-Mail) hiervon unverzüglich zu informieren und die Nachricht zu löschen. Jede unerlaubte Nutzung oder Weitergabe des Inhalts dieser Nachricht, sei es vollständig oder teilweise, ist unzulässig. Bitte beachten Sie, dass E-Mail-Nachrichten an den Absender nicht für fristgebundene Mitteilungen geeignet sind. Fristgebundene Mitteilungen sind daher ausschließlich per Post oder per Telefax zu übersenden.

Re: Using md5 authentication

От
Philip Poloczek
Дата:
So isn't there any way to directly use a hash as password?
I want to store the password locally as a hash instead of plain text for security reasons.


Am 31.07.2013 09:43, schrieb Athanasios Kostopoulos:
From the manual:
"The password-based authentication methods are md5 and password. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively."

so you still have to specify the password and not the hash of it in your .pgpass or manual connection string.


On Wed, Jul 31, 2013 at 9:17 AM, Philip Poloczek <Philip.Poloczek@dlr.de> wrote:
Hello,

I want to connect to my database using a md5 hash instead of the plain password, so i changed the authentication method in the pg_hba.conf to md5 instead of password.
example: i want to use '5f4dcc3b5aa765d61d8327deb882cf99' instead of 'password' in the login mask.

But until now i didn't get it working, i still can connect to the database with the plain password but not with the corresponding md5 Hash. When i'am using the md5 hash i just get a FATAL error for password authentication. I used pg_ctl to reload the pg_hba.conf and also restarted the server.

Also the md5 hash which is saved for the users in the database differs from my created ones for that specific password. I read that the passwords are salted before encrypted with a part of the usernames? But even if i use these md5 hashes as password input, i can not connect and get a FATAL error.

BTW is it possible to use SHA-1 encrypted passwords with postgresql?

I'am currently using postgresql 8.4.

pg_hba.conf
local   all         all                                md5
host    all         all         127.0.0.1/32           md5

Best recards,
pp


--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice


classmarkets GmbH | Schumannstraße 6 | 10117 Berlin | Deutschland
Tel: +49 (0)30 56 59 001-0 | Fax: +49 (0)30 56 59 001-99 | www.classmarkets.com

Amtsgericht Charlottenburg HRB 111815 B | USt.Id.Nr: DE 260731582
Geschäftsführer: Veit Mürz, Fabian Ströhle

Diese Nachricht (inklusive aller Anhänge) ist vertraulich. Sie darf ausschließlich durch den vorgesehenen Empfänger und Adressaten gelesen, kopiert oder genutzt werden. Sollten Sie diese Nachricht versehentlich erhalten haben, bitten wir, den Absender (durch Antwort-E-Mail) hiervon unverzüglich zu informieren und die Nachricht zu löschen. Jede unerlaubte Nutzung oder Weitergabe des Inhalts dieser Nachricht, sei es vollständig oder teilweise, ist unzulässig. Bitte beachten Sie, dass E-Mail-Nachrichten an den Absender nicht für fristgebundene Mitteilungen geeignet sind. Fristgebundene Mitteilungen sind daher ausschließlich per Post oder per Telefax zu übersenden.



--
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
Institut für Aerodynamik und Strömungstechnik | Abteilung Raumfahrzeuge | Bunsenstr. 10 | 37073 Göttingen

Philip Poloczek | Dualer Student (DHBW-Mannheim)
Telefon 0551 709-2343 | Philip.Poloczek@dlr.de
www.DLR.de

Re: Using md5 authentication

От
Athanasios Kostopoulos
Дата:
AFAIK, the permissions of .pgpass (0600) take care of security reasons.


On Wed, Jul 31, 2013 at 9:55 AM, Philip Poloczek <Philip.Poloczek@dlr.de> wrote:
So isn't there any way to directly use a hash as password?
I want to store the password locally as a hash instead of plain text for security reasons.


Am 31.07.2013 09:43, schrieb Athanasios Kostopoulos:
From the manual:
"The password-based authentication methods are md5 and password. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively."

so you still have to specify the password and not the hash of it in your .pgpass or manual connection string.


On Wed, Jul 31, 2013 at 9:17 AM, Philip Poloczek <Philip.Poloczek@dlr.de> wrote:
Hello,

I want to connect to my database using a md5 hash instead of the plain password, so i changed the authentication method in the pg_hba.conf to md5 instead of password.
example: i want to use '5f4dcc3b5aa765d61d8327deb882cf99' instead of 'password' in the login mask.

But until now i didn't get it working, i still can connect to the database with the plain password but not with the corresponding md5 Hash. When i'am using the md5 hash i just get a FATAL error for password authentication. I used pg_ctl to reload the pg_hba.conf and also restarted the server.

Also the md5 hash which is saved for the users in the database differs from my created ones for that specific password. I read that the passwords are salted before encrypted with a part of the usernames? But even if i use these md5 hashes as password input, i can not connect and get a FATAL error.

BTW is it possible to use SHA-1 encrypted passwords with postgresql?

I'am currently using postgresql 8.4.

pg_hba.conf
local   all         all                                md5
host    all         all         127.0.0.1/32           md5

Best recards,
pp


--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice


classmarkets GmbH | Schumannstraße 6 | 10117 Berlin | Deutschland
Tel: +49 (0)30 56 59 001-0 | Fax: +49 (0)30 56 59 001-99www.classmarkets.com

Amtsgericht Charlottenburg HRB 111815 B | USt.Id.Nr: DE 260731582
Geschäftsführer: Veit Mürz, Fabian Ströhle

Diese Nachricht (inklusive aller Anhänge) ist vertraulich. Sie darf ausschließlich durch den vorgesehenen Empfänger und Adressaten gelesen, kopiert oder genutzt werden. Sollten Sie diese Nachricht versehentlich erhalten haben, bitten wir, den Absender (durch Antwort-E-Mail) hiervon unverzüglich zu informieren und die Nachricht zu löschen. Jede unerlaubte Nutzung oder Weitergabe des Inhalts dieser Nachricht, sei es vollständig oder teilweise, ist unzulässig. Bitte beachten Sie, dass E-Mail-Nachrichten an den Absender nicht für fristgebundene Mitteilungen geeignet sind. Fristgebundene Mitteilungen sind daher ausschließlich per Post oder per Telefax zu übersenden.



--
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
Institut für Aerodynamik und Strömungstechnik | Abteilung Raumfahrzeuge | Bunsenstr. 10 | 37073 Göttingen

Philip Poloczek | Dualer Student (DHBW-Mannheim)
Telefon 0551 709-2343 | Philip.Poloczek@dlr.de
www.DLR.de


classmarkets GmbH | Schumannstraße 6 | 10117 Berlin | Deutschland
Tel: +49 (0)30 56 59 001-0 | Fax: +49 (0)30 56 59 001-99 | www.classmarkets.com

Amtsgericht Charlottenburg HRB 111815 B | USt.Id.Nr: DE 260731582
Geschäftsführer: Veit Mürz, Fabian Ströhle

Diese Nachricht (inklusive aller Anhänge) ist vertraulich. Sie darf ausschließlich durch den vorgesehenen Empfänger und Adressaten gelesen, kopiert oder genutzt werden. Sollten Sie diese Nachricht versehentlich erhalten haben, bitten wir, den Absender (durch Antwort-E-Mail) hiervon unverzüglich zu informieren und die Nachricht zu löschen. Jede unerlaubte Nutzung oder Weitergabe des Inhalts dieser Nachricht, sei es vollständig oder teilweise, ist unzulässig. Bitte beachten Sie, dass E-Mail-Nachrichten an den Absender nicht für fristgebundene Mitteilungen geeignet sind. Fristgebundene Mitteilungen sind daher ausschließlich per Post oder per Telefax zu übersenden.

Re: Using md5 authentication

От
Philip Poloczek
Дата:
It's kind of secure. These passwords are very sensitive, i don't even want administrators to read these passwords in plain text. Maybe i should use ldap.

Am 31.07.2013 10:10, schrieb Athanasios Kostopoulos:
AFAIK, the permissions of .pgpass (0600) take care of security reasons.


On Wed, Jul 31, 2013 at 9:55 AM, Philip Poloczek <Philip.Poloczek@dlr.de> wrote:
So isn't there any way to directly use a hash as password?
I want to store the password locally as a hash instead of plain text for security reasons.


Am 31.07.2013 09:43, schrieb Athanasios Kostopoulos:
From the manual:
"The password-based authentication methods are md5 and password. These methods operate similarly except for the way that the password is sent across the connection, namely MD5-hashed and clear-text respectively."

so you still have to specify the password and not the hash of it in your .pgpass or manual connection string.


On Wed, Jul 31, 2013 at 9:17 AM, Philip Poloczek <Philip.Poloczek@dlr.de> wrote:
Hello,

I want to connect to my database using a md5 hash instead of the plain password, so i changed the authentication method in the pg_hba.conf to md5 instead of password.
example: i want to use '5f4dcc3b5aa765d61d8327deb882cf99' instead of 'password' in the login mask.

But until now i didn't get it working, i still can connect to the database with the plain password but not with the corresponding md5 Hash. When i'am using the md5 hash i just get a FATAL error for password authentication. I used pg_ctl to reload the pg_hba.conf and also restarted the server.

Also the md5 hash which is saved for the users in the database differs from my created ones for that specific password. I read that the passwords are salted before encrypted with a part of the usernames? But even if i use these md5 hashes as password input, i can not connect and get a FATAL error.

BTW is it possible to use SHA-1 encrypted passwords with postgresql?

I'am currently using postgresql 8.4.

pg_hba.conf
local   all         all                                md5
host    all         all         127.0.0.1/32           md5

Best recards,
pp


--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice


classmarkets GmbH | Schumannstraße 6 | 10117 Berlin | Deutschland
Tel: +49 (0)30 56 59 001-0 | Fax: +49 (0)30 56 59 001-99www.classmarkets.com

Amtsgericht Charlottenburg HRB 111815 B | USt.Id.Nr: DE 260731582
Geschäftsführer: Veit Mürz, Fabian Ströhle

Diese Nachricht (inklusive aller Anhänge) ist vertraulich. Sie darf ausschließlich durch den vorgesehenen Empfänger und Adressaten gelesen, kopiert oder genutzt werden. Sollten Sie diese Nachricht versehentlich erhalten haben, bitten wir, den Absender (durch Antwort-E-Mail) hiervon unverzüglich zu informieren und die Nachricht zu löschen. Jede unerlaubte Nutzung oder Weitergabe des Inhalts dieser Nachricht, sei es vollständig oder teilweise, ist unzulässig. Bitte beachten Sie, dass E-Mail-Nachrichten an den Absender nicht für fristgebundene Mitteilungen geeignet sind. Fristgebundene Mitteilungen sind daher ausschließlich per Post oder per Telefax zu übersenden.



--
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
Institut für Aerodynamik und Strömungstechnik | Abteilung Raumfahrzeuge | Bunsenstr. 10 | 37073 Göttingen

Philip Poloczek | Dualer Student (DHBW-Mannheim)
Telefon 0551 709-2343 | Philip.Poloczek@dlr.de
www.DLR.de


classmarkets GmbH | Schumannstraße 6 | 10117 Berlin | Deutschland
Tel: +49 (0)30 56 59 001-0 | Fax: +49 (0)30 56 59 001-99 | www.classmarkets.com

Amtsgericht Charlottenburg HRB 111815 B | USt.Id.Nr: DE 260731582
Geschäftsführer: Veit Mürz, Fabian Ströhle

Diese Nachricht (inklusive aller Anhänge) ist vertraulich. Sie darf ausschließlich durch den vorgesehenen Empfänger und Adressaten gelesen, kopiert oder genutzt werden. Sollten Sie diese Nachricht versehentlich erhalten haben, bitten wir, den Absender (durch Antwort-E-Mail) hiervon unverzüglich zu informieren und die Nachricht zu löschen. Jede unerlaubte Nutzung oder Weitergabe des Inhalts dieser Nachricht, sei es vollständig oder teilweise, ist unzulässig. Bitte beachten Sie, dass E-Mail-Nachrichten an den Absender nicht für fristgebundene Mitteilungen geeignet sind. Fristgebundene Mitteilungen sind daher ausschließlich per Post oder per Telefax zu übersenden.



--
Deutsches Zentrum für Luft- und Raumfahrt e.V. (DLR)
Institut für Aerodynamik und Strömungstechnik | Abteilung Raumfahrzeuge | Bunsenstr. 10 | 37073 Göttingen

Philip Poloczek | Dualer Student (DHBW-Mannheim)
Telefon 0551 709-2343 | Philip.Poloczek@dlr.de
www.DLR.de

Re: Using md5 authentication

От
"ktm@rice.edu"
Дата:
On Wed, Jul 31, 2013 at 10:25:03AM +0200, Philip Poloczek wrote:
> It's kind of secure. These passwords are very sensitive, i don't
> even want administrators to read these passwords in plain text.
> Maybe i should use ldap.
>

Hi Philip,

Storing a hash of a password that you could use is the same as
storing the plain text password with the same security concerns.
As you suspect, using something like ldap, gssapi or a multi-
factor authentication scheme is much, much better.

Regards,
Ken


really novice with Postgres !

От
Jean MAURICE
Дата:
Hi,

Last year I tried to work with Postgres and Pgadmin3. It was successfull but it
was just a try. On the other hand, I work with Visual Foxpro since its first
version (on VFP mailing list my nickname is 'foxil' = Fox + fossile) !

Today I want to create a real database with a challenge : I want to build it
from within VFP (my customer is far and teamviewer is not allowed !).

My first questions are about 'main things'. Can someone answers yes or no to :

1) I would like to define a tablespace : here on my PC it will be something like
"D:\POSTRGRES\KM and in my customer's site something like '10.12.2.52\tp\km\'.
It's ok ?

2) 'in' this tablespace, I want to create a database (I think it's the more easy !)

3) in the database, I want to create a schema 'edp' because, in this first shot,
we will work only with a set of tables, views, index, ... In the future, we will
work with a new set of tables, ... and I'll create a second schema. In few
words, first shema is about 'real things', the second will be accounting,
invoices, ...

4) my first idea is to use ODBC. Can we connect to 'postgres' only by omitting
the 'database=' clause in the connection string. At the very beginning, there
will have no database in postgres !

thanks in advance

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org



Re: really novice with Postgres !

От
raghu ram
Дата:

On Thu, Aug 1, 2013 at 7:23 PM, Jean MAURICE <mauricejea@numericable.fr> wrote:
Hi,

Last year I tried to work with Postgres and Pgadmin3. It was successfull but it was just a try. On the other hand, I work with Visual Foxpro since its first version (on VFP mailing list my nickname is 'foxil' = Fox + fossile) !

Today I want to create a real database with a challenge : I want to build it from within VFP (my customer is far and teamviewer is not allowed !).

My first questions are about 'main things'. Can someone answers yes or no to :

1) I would like to define a tablespace : here on my PC it will be something like "D:\POSTRGRES\KM and in my customer's site something like '10.12.2.52\tp\km\'. It's ok ?


I am assuming "10.12.2.52\tp\km\" is network storage drive. Creating Tablespace folder in Network drive will create few performance issues.

2) 'in' this tablespace, I want to create a database (I think it's the more easy !)

Yes,You can create a database and assign tablespace as a default tablespace for newly created database.
 

3) in the database, I want to create a schema 'edp' because, in this first shot, we will work only with a set of tables, views, index, ... In the future, we will work with a new set of tables, ... and I'll create a second schema. In few words, first shema is about 'real things', the second will be accounting, invoices, ...


This is really a good approach..
 
4) my first idea is to use ODBC. Can we connect to 'postgres' only by omitting the 'database=' clause in the connection string. At the very beginning, there will have no database in postgres !

By default there databases are created at the time of PostgreSQL Installation i.e template0,template1,postgres. If you omit the database clause,then you will connect only "postgres" default database.

edb:bin postgres$ /Library/PostgreSQL/9.1/bin/psql
psql (9.1.3)
Type "help" for help.
postgres=# 

Thanks & Regards
Raghu Ram
SkypeID: raghu.ramedb
 

Re: really novice with Postgres !

От
Jean MAURICE
Дата:
Le 01/08/2013 17:28, raghu ram a écrit :
>
> I am assuming "10.12.2.52\tp\km\" is network storage drive. Creating
> Tablespace folder in Network drive will create few performance issues.
>
You're answer made me think that I made a mistake : the TABLESPACE is relative
to Postgres and not to the VFP application !

Thanks for your answers.



really novice with Postgres !

От
Jean MAURICE
Дата:
Hi everybody,

I have some more questions :
Is there a SQL command to
  - test if a database exists
  - test if a table exists
  - get the list of the tables of a database
  - get the structure (list of fields) of a table

Thanks in advance

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org


Re: really novice with Postgres !

От
Ziggy Skalski
Дата:
On 2013-08-02 2:51 PM, Jean MAURICE wrote:
> Hi everybody,
>
> I have some more questions :
> Is there a SQL command to
>  - test if a database exists
>  - test if a table exists
>  - get the list of the tables of a database
>  - get the structure (list of fields) of a table
>
> Thanks in advance
>
> --
> Jean MAURICE
> Grenoble - France - Europe
> www.j-maurice.fr
> www.atoutfox.org
> www.aedtf.org
>
>
Off top of my head, \dt will get you list of tables and \d [tablename]
will show the structure...
You can type \? at psql prompt for more commands/etc.

Ziggy



Re: really novice with Postgres !

От
Tovo Rabemanantsoa
Дата:
On 08/02/2013 02:51 PM, Jean MAURICE wrote:
> Hi everybody,
>
> I have some more questions :
> Is there a SQL command to
>  - test if a database exists
>  - test if a table exists
>  - get the list of the tables of a database
>  - get the structure (list of fields) of a table
>
> Thanks in advance
>
> --
> Jean MAURICE
> Grenoble - France - Europe
> www.j-maurice.fr
> www.atoutfox.org
> www.aedtf.org
>
>
Hello Jean,
With Postgresql, you have something called information schema [1].
In that, you will find all the informations you need about you
databases, tables and so on.
Cheers

[1]http://www.postgresql.org/docs/current/static/information-schema.html


Re: really novice with Postgres !

От
raghu ram
Дата:

On Fri, Aug 2, 2013 at 6:21 PM, Jean MAURICE <mauricejea@numericable.fr> wrote:
Hi everybody,

I have some more questions :
Is there a SQL command to
 - test if a database exists
postgres=# select * from pg_database where datname='<DB name>';

  or
postgres=# \l
 
 - test if a table exists

postgres=# select * from pg_class where rename='<tablename>';
 
 
 - get the list of the tables of a database

 postgres=# \dt

       or
postgres=# select * from pg_class

 - get the structure (list of fields) of a table

 
 postgres=# \d <tablename>

Thanks & Regards
Raghu Ram

Re: really novice with Postgres !

От
Jean MAURICE
Дата:
Hi Ziggy,

I thank you but I search SQL commands because I want to create a database +
table + ... from with Visual Foxpro !!

A+

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org


Re: really novice with Postgres !

От
Jean MAURICE
Дата:
Hi Tovo,

I saw there is a view 'tables' that gives the list of the tables. How do we use
a view in Postgres ?
I tried
SELECT * FROM tables;
but the error is something like 'the relation 'tables' doesn't exist' (my
Postgres is in French !)

Best regards

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org

Le 02/08/2013 15:01, Tovo Rabemanantsoa a écrit :
> On 08/02/2013 02:51 PM, Jean MAURICE wrote:
>> Hi everybody,
>>
>> I have some more questions :
>> Is there a SQL command to
>>   - test if a database exists
>>   - test if a table exists
>>   - get the list of the tables of a database
>>   - get the structure (list of fields) of a table
>>
>> Thanks in advance
>>
>> --
>> Jean MAURICE
>> Grenoble - France - Europe
>> www.j-maurice.fr
>> www.atoutfox.org
>> www.aedtf.org
>>
>>
> Hello Jean,
> With Postgresql, you have something called information schema [1].
> In that, you will find all the informations you need about you
> databases, tables and so on.
> Cheers
>
> [1]http://www.postgresql.org/docs/current/static/information-schema.html
>
>


Re: really novice with Postgres !

От
Tovo Rabemanantsoa
Дата:
On 08/02/2013 03:31 PM, Jean MAURICE wrote:
> Hi Tovo,
>
> I saw there is a view 'tables' that gives the list of the tables. How do
> we use a view in Postgres ?
> I tried
> SELECT * FROM tables;
> but the error is something like 'the relation 'tables' doesn't exist'
> (my Postgres is in French !)
>
> Best regards
>

It's quite simple, for example, if you want to list tables by using the
view tables, you make the following query :
SELECT * FROM information_schema.tables
Et voilà


Re: really novice with Postgres !

От
"Kevin Salisbury"
Дата:
Jean,

Have you tried pgdbf?

http://pgdbf.sourceforge.net/

I'm not sure you can do it easily from *within* VFP, but I know you can do it from the DBF itself and python using
pgdbfon Linux. pgdbf works very nicely with VFP 9 tables and postgres 9.x - it creates postgres tables based on your
DBFwith postgres index(es) as needed too. The creator is responsive to  questions. Please note that the python code is
movingoff sourceforge and onto git (which is noted on the main website as well); https://github.com/kstrauser/pgdbf 

A little google searching on VFP & python - there may be a way to launch python scripts using VFP;
http://abitofscript.blogspot.com/

Kevin

>>> Jean MAURICE <mauricejea@numericable.fr> 8/2/2013 9:07 AM >>>
Hi Ziggy,

I thank you but I search SQL commands because I want to create a database +
table + ... from with Visual Foxpro !!

A+

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org


--
Sent via pgsql-novice mailing list (pgsql-novice@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice




Re: really novice with Postgres !

От
Jean MAURICE
Дата:
Thanks Kevin, I'll have a look at it ...

but now, I want do 'upgrade' datas from VFP to Postgres 'step by step' and
'automatically'. I have a customer (1200 workers) who have this huge VFP app
(roads, homes, ... building from price calculation to 'work management' (hope
you understand)). This app was build in 1996. For a year, I am improving it
within VFP. He has a new 'computer scientist' who is a fan of Postgres and I
agree with him to upgrade datas to posgres. But it's a long way to go ...

For me, it's the first time I do such an upgrade but it is not the last one. I
mean : VFP client + Postgres database is a very efficient 'couple' and customers
have 'relief' when they know that datas are not in VFP !

Best Regards

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org

Le 02/08/2013 16:05, Kevin Salisbury a écrit :
> Jean,
>
> Have you tried pgdbf?
>
> http://pgdbf.sourceforge.net/
>
> I'm not sure you can do it easily from *within* VFP, but I know you can do it from the DBF itself and python using
pgdbfon Linux. pgdbf works very nicely with VFP 9 tables and postgres 9.x - it creates postgres tables based on your
DBFwith postgres index(es) as needed too. The creator is responsive to  questions. Please note that the python code is
movingoff sourceforge and onto git (which is noted on the main website as well); https://github.com/kstrauser/pgdbf 
>
> A little google searching on VFP&  python - there may be a way to launch python scripts using VFP;
> http://abitofscript.blogspot.com/
>
> Kevin
>


Re: really novice with Postgres !

От
Steve Crawford
Дата:
Hi Jean,

First, as a novice you will soon find someone telling you that the
convention on the PostgreSQL mailing list is to "bottom post", i.e. post
your reply below the message you are replying to so people can read the
full history top to bottom.

On 08/02/2013 06:31 AM, Jean MAURICE wrote:
> Hi Tovo,
>
> I saw there is a view 'tables' that gives the list of the tables. How
> do we use a view in Postgres ?
> I tried
> SELECT * FROM tables;
> but the error is something like 'the relation 'tables' doesn't exist'
> (my Postgres is in French !)
>
Initial learning curves are always steep. In PostgreSQL tables are
organized into sets called "schemas." In a default installation the
tables will typically be in a schema called "public." It's easy to be
unaware that this is happening because, also by default, the "public"
schema is in your search path. You can check your search path with the
"show search_path;" statement.

Another schema is the "pg_catalog" schema which is visible by default
and contains lots of tables/pseudo-tables/views that underpin the inner
workings of PostgreSQL but which can be useful for the types of queries
you seek.

The information_schema is not in your search path by default but also
contains tables/views that can help you (and which are generally easier
to use than the pg_catalog tables). To access a table either explicitly
(due to the same table-name existing in multiple schemas in the search
path) or because the schema is not in the search path, simply prepend
the schema to the table, i.e. "select * from information_schema.columns
where table_name='foo' and table_schema='public';".
I have some more questions :
>>> Is there a SQL command to
>>>   - test if a database exists
Look in pg_catalog.pg_database
>>>   - test if a table exists
information_schema.tables
>>>   - get the list of the tables of a database
information_schema.tables again
>>>   - get the structure (list of fields) of a table
information_schema.columns

One trick is to run the "psql" terminal with the "-E" option. This will
cause it to show the actual commands it sends to the server in response
to the various backslash commands. For example if you want to see a list
of table (\dt) it would show the command it sent to the server:

********* QUERY **********
SELECT n.nspname as "Schema",
   c.relname as "Name",
   CASE c.relkind WHEN 'r' THEN 'table' WHEN 'v' THEN 'view' WHEN 'i'
THEN 'index' WHEN 'S' THEN 'sequence' WHEN 's' THEN 'special' WHEN 'f'
THEN 'foreign table' END as "Type",
   pg_catalog.pg_get_userbyid(c.relowner) as "Owner"
FROM pg_catalog.pg_class c
      LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','')
       AND n.nspname <> 'pg_catalog'
       AND n.nspname <> 'information_schema'
       AND n.nspname !~ '^pg_toast'
   AND pg_catalog.pg_table_is_visible(c.oid)
ORDER BY 1,2;
**************************

You can use that query as a jumping off point to learn where the data is
located or to modify the query to suit your use.

Cheers,
Steve



Re: really novice with Postgres !

От
"Kevin Salisbury"
Дата:
>>> Jean MAURICE <mauricejea@numericable.fr> 8/2/2013 10:47 AM >>>
<...>
but now, I want do 'upgrade' datas from VFP to Postgres 'step by step' and
'automatically'. I have a customer (1200 workers) who have this huge VFP app
(roads, homes, ... building from price calculation to 'work management' (hope
you understand)). This app was build in 1996. For a year, I am improving it
within VFP. He has a new 'computer scientist' who is a fan of Postgres and I
agree with him to upgrade datas to posgres. But it's a long way to go ...

For me, it's the first time I do such an upgrade but it is not the last one. I
mean : VFP client + Postgres database is a very efficient 'couple' and customers
have 'relief' when they know that datas are not in VFP !
<...>

Jean,

pgdbf will allow you to convert data once from vfp to new Postgres table(s) every time you run it. It's static if that
makessense. You can schedule synchronizing - how long it takes to synchronize depends solely on your hardware and
amountof VFP data you have. Converting to postgres is an excellent idea - it will allow your customer to access
numerousbusiness intelligence / reporting capabilities right away. If you cannot redesign the clients quickly, then it
isalso possible to configure your VFP clients to access the postgresql tables instead of dbf (via the postgres ODBC
driver).Start here; 

http://postgresql.1045698.n5.nabble.com/Very-basic-question-from-a-beginner-td5626124.html

Regards,

Kevin



really novice with Postgres !

От
Jean MAURICE
Дата:
Hi to all,

I am 'going fast' with your help in building my postgres database from within VFP.

I can check if the database is present, if a table is present, ... but how can I
check if a schema is present (via ODBC; I can see it in pgadmin3 !) ?

CREATE SCHEMA testedp AUTHORIZATION postgres;
COMMENT ON SCHEMA testedp IS 'test';

I 'browsed' a lot of pg_* tables unsuccesffully !

Best Regards

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org


Re: really novice with Postgres !

От
Kevin Grittner
Дата:
Jean MAURICE <mauricejea@numericable.fr> wrote:

> I can check if the database is present, if a table is present,
> ... but how can I check if a schema is present (via ODBC; I can
> see it in pgadmin3 !) ?

See pg_catalog.pg_namespace or information_schema.schemata.

A SQL "schema" object is often called a "namespace".

BTW, a subject line which is related to the question is a good idea
-- you might have used "What system table or view for schemas?" or
similar.  Given the volume of posts to these lists, many people
scan the list of subject lines and pick only some to read.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: really novice with Postgres !

От
Jean MAURICE
Дата:
Le 03/08/2013 19:53, Kevin Grittner a écrit :
> Jean MAURICE<mauricejea@numericable.fr>  wrote:
>
>> I can check if the database is present, if a table is present,
>> ... but how can I check if a schema is present (via ODBC; I can
>> see it in pgadmin3 !) ?
> See pg_catalog.pg_namespace or information_schema.schemata.
ok
> A SQL "schema" object is often called a "namespace".
registered !
>
> BTW, a subject line which is related to the question is a good idea
> -- you might have used "What system table or view for schemas?" or
> similar.  Given the volume of posts to these lists, many people
> scan the list of subject lines and pick only some to read.
I'll pay attention to it
> --
> Kevin Grittner
> EDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
Thanks

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org
> -----
> Aucun virus trouvé dans ce message.
> Analyse effectuée par AVG - www.avg.fr
> Version: 2013.0.3392 / Base de données virale: 3209/6548 - Date: 03/08/2013
>
>
>


'moving' from one database to another

От
Jean MAURICE
Дата:
As I explained, I am trying to built a complete Postgres database from within
VFP through ODBC.

When I start with 'nothing' (I mean Postgres is installed), I connect to the
database 'postgres'. I can then test if the database I want is already built and
I build it if not.

But once it is built, can I 'move' from the default database to my new database
with a command OR must I disconnect from postgres and reconnect to my new
database ? In Visual Foxpro, we have a command "SET DATABASE TO mydatabase" and
it is exactly what I want to do !

Thanks in advance

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org


Re: 'moving' from one database to another

От
Kevin Grittner
Дата:
Jean MAURICE <mauricejea@numericable.fr> wrote:

> I connect to the database 'postgres'. I can then test if the
> database I want is already built and I build it if not.
>
> But once it is built, can I 'move' from the default database to
> my new database with a command OR must I disconnect from postgres
> and reconnect to my new database ? In Visual Foxpro, we have a
> command "SET DATABASE TO mydatabase" and it is exactly what I
> want to do !

In PostgreSQL a connection is to a particular database.  To use a
different database you must establish a new connection.  The psql
client software provides an easy way to do that with \c, but behind
the scenes that closes the existing connection and opens a new one.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: 'moving' from one database to another

От
Tom Lane
Дата:
Kevin Grittner <kgrittn@ymail.com> writes:
> Jean MAURICE <mauricejea@numericable.fr> wrote:
>> I connect to the database 'postgres'. I can then test if the
>> database I want is already built and I build it if not.
>>
>> But once it is built, can I 'move' from the default database to
>> my new database with a command OR must I disconnect from postgres
>> and reconnect to my new database ? In Visual Foxpro, we have a
>> command "SET DATABASE TO mydatabase" and it is exactly what I
>> want to do !

> In PostgreSQL a connection is to a particular database.� To use a
> different database you must establish a new connection.� The psql
> client software provides an easy way to do that with \c, but behind
> the scenes that closes the existing connection and opens a new one.

It's entirely likely that what you really want to approximate Foxpro with
is not multiple databases, but multiple schemas within a single database.

            regards, tom lane


Re: 'moving' from one database to another

От
Jean MAURICE
Дата:
Le 03/08/2013 22:51, Tom Lane a écrit :
>>   In Visual Foxpro, we have a
>> command "SET DATABASE TO mydatabase" and it is exactly what I
>> want to do !
>> In PostgreSQL a connection is to a particular database.  To use a
>> different database you must establish a new connection.  The psql
>> client software provides an easy way to do that with \c, but behind
>> the scenes that closes the existing connection and opens a new one.
ok.
> It's entirely likely that what you really want to approximate Foxpro with
> is not multiple databases, but multiple schemas within a single database.
>
no ! I know about database and schemas. My problem is only the first time I
connect to postgres to build my 'own' database. Once it is built, I want to work
on it ... and build schemas.
Disconnect() and connect() again is, then, not a big drawback.

Many thanks

--
Jean MAURICE
Grenoble - France - Europe
www.j-maurice.fr
www.atoutfox.org
www.aedtf.org