Thread

  1. current database?

    mikeo <mikeo@spectrumtelecorp.com> — 2000-06-19T16:07:05Z

    hi,
     when i do \c - postgres tells me which
    database i'm currently connected to.  where
    does it get this info?  i'd like to use it
    in a program.  
    
    TIA,
      mikeo  
    
    
  2. Re: current database?

    Peter Eisentraut <peter_e@gmx.net> — 2000-06-19T17:04:55Z

    mikeo writes:
    
    >  when i do \c - postgres tells me which
    > database i'm currently connected to.  where
    > does it get this info?  i'd like to use it
    > in a program.  
    
    It remembers this information from when you first connected, e.g., `psql
    -d template1'.
    
    -- 
    Peter Eisentraut                  Sernanders väg 10:115
    peter_e@gmx.net                   75262 Uppsala
    http://yi.org/peter-e/            Sweden
    
    
    
  3. Re: current database?

    Tom Lane <tgl@sss.pgh.pa.us> — 2000-06-19T18:16:19Z

    mikeo <mikeo@spectrumtelecorp.com> writes:
    >  when i do \c - postgres tells me which
    > database i'm currently connected to.  where
    > does it get this info?  i'd like to use it
    > in a program.  
    
    If you're working directly with libpq, then PQdb() et al return
    the connection parameters used to create the current PGconn object.
    
    			regards, tom lane