         opts = defaults opts,
             host         : process.env['PGHOST'] ? 'localhost'    # or 'hostname:port'
             database     : process.env['SMC_DB'] ? 'smc'
+            user         : process.env['PGUSER'] ? 'smc'
             debug        : true
             connect      : true
             password     : undefined

        else
            @_host = opts.host
            @_port = 5432
        @_database = opts.database
        @_concurrent_queries = 0
        @_password = opts.password ? read_password_from_disk()

    _ensure_database_exists: (cb) =>
        dbg = @_dbg("_ensure_database_exists")
        dbg("ensure database '#{@_database}' exists")
        args = ['--user', @_user, '--host', @_host, '--port', @_port, '--list', '--tuples-only']
        dbg("psql #{args.join(' ')}")
        misc_node.execute_code
            command : 'psql'
