I appologize for kind of information I gave to you. I have tried to present 
an minimal working example, and figured out, that I missed a lot of 
information.

Let's try it again. :-) 
        
        require 'sequel'
        require 'pg'
        require 'logger'
        
        # ===============================================
        # Constants
        # ===============================================
        DIR_SCRIPT          = __dir__
        DIR_DATA            = File.join(DIR_SCRIPT, 'data')
        DIR_DATABASE        = File.join(DIR_SCRIPT, 'db')
        DIR_PARSING_RESULTS = File.join(DIR_SCRIPT, 'results')
        DATABASE_TYPE = 'pg'
        
        begin
          
          puts "Database"
          puts "--------"
          
          case DATABASE_TYPE.downcase
          when 'pg', 'postgres', 'postgresql'
            SERVER   = 'localhost'
            DATABASE = 'psa'
            SCHEMA   = 'rmrst'
            PORT     = 5432
            USER     = 'test'
            PWD      = '1234'
            
            puts "  -> Connecting to Postgres-Database 'PSA' as user 
#{USER}'"
            db_logger       = Logger.new(File.join(DIR_DATABASE, 
'Postgres_PSA.log'))
            db_logger.level = Logger::DEBUG
            
            # Note 1: First connection
            DB = Sequel.postgres(:host          => SERVER,
                                 :port          => PORT,
                                 :database      => DATABASE,
                                 :search_path   => SCHEMA,
                                 :user          => USER,
                                 :password      => PWD,
                                 :logger        => db_logger
            )
          
          else
            db_file = File.join(DIR_DATABASE, 'RiskmanResults.sqlite')
            puts "  -> Connecting to Sqlite3-Database: #{db_file}"
            DB = Sequel.sqlite("#{db_file}")
          end
          
          models = DB[:models]   # Note 2: Is here perhaps a second 
connection to the database?
          puts models.count
         
        end
 
 And here is the log-File:
 
        # Logfile created on 2018-04-27 16:42:52 +0200 by logger.rb/61378
        I, [2018-04-27T16:42:52.533784 #11736]  INFO -- : (0.000666s) SET 
standard_conforming_strings = ON
        I, [2018-04-27T16:42:52.534979 #11736]  INFO -- : (0.000382s) SET 
client_min_messages = 'WARNING'
        I, [2018-04-27T16:42:52.535871 #11736]  INFO -- : (0.000387s) SET 
search_path = "rmrst"
        I, [2018-04-27T16:42:52.536717 #11736]  INFO -- : (0.000360s) SET 
DateStyle = 'ISO'
        I, [2018-04-27T16:42:52.540509 #11736]  INFO -- : (0.002814s) 
SELECT CAST(current_setting('server_version_num') AS integer) AS v
        E, [2018-04-27T16:42:52.546959 #11736] ERROR -- : 
PG::UndefinedTable: FEHLER:  Relation »models« existiert nicht
        LINE 1: SELECT count(*) AS "count" FROM "models" LIMIT 1
                                                ^: SELECT count(*) AS 
"count" FROM "models" LIMIT 1
                                                
My questions are:

1. How many connections to I have? I assumed, that there is only one 
connection (see Note 1). As I can see in my database log, the search path 
is set correctly.
2. When I call DB[:models] (see Note 2), do I create a new connection or is 
the first one still valid?  If yes, that I assume, that the settings to the 
search_path are not valid anymore.
  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to